ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•

๊ธฐ๋ณธ์ ์œผ๋กœ ์ธ์Šคํƒ€๊ทธ๋žจ์€ ๋กœ๊ทธ์ธ์„ ํ•ด์•ผ ๋ชจ๋“  ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋จผ์ € ํšŒ์›(์œ ์ €)์— ๊ด€ํ•œ ๋กœ์ง๋ถ€ํ„ฐ ์ž‘์„ฑํ•ด๋ณด๊ฒ ๋‹ค.

 

Model


UsersVO ํšŒ์› ๋ชจ๋ธ ์ƒ์„ฑ

package com.hastagram.myapp.users.model;

import java.util.Date;

import org.springframework.web.multipart.MultipartFile;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
public class UsersVO {

	private int userNo;		//ํšŒ์› ๋ฒˆํ˜ธ
	private String email;		//ํšŒ์› ์ด๋ฉ”์ผ
	private String id;		//ํšŒ์› ์•„์ด๋””
	private String pw;		//ํŒจ์Šค์›Œ๋“œ
	private String name;		//ํšŒ์› ์ด๋ฆ„
	private String intro;		//์†Œ๊ฐœ๋ง
	private String phone;		//์ „ํ™”๋ฒˆํ˜ธ
	private Date regDate;		//๋“ฑ๋ก๋‚ ์งœ
	
	//ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ ๋„˜์–ด์˜จ ํŒŒ์ผ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ํŒŒ๋ผ๋ฏธํ„ฐ ์ฝ๊ธฐ์šฉ
	private MultipartFile file;
	
	//ํ”„๋กœํ•„ ํŒŒ์ผ์„ ์œ„ํ•œ ํ•„๋“œ
	private int userImgNo;
	private String profileName;			//ํŒŒ์ผ ์ด๋ฆ„
	private long profileSize;			//ํŒŒ์ผ ํฌ๊ธฐ
	private String profileContentType;		//ํŒŒ์ผ ํƒ€์ž…
	
}

ํšŒ์›์—์„œ ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์€ ํ•„๋“œ๋“ค์„ ์ƒ์„ฑํ•˜์˜€๋‹ค.

 

UserImgsVO ํšŒ์› ํ”„๋กœํ•„ ์‚ฌ์ง„ ๋ชจ๋ธ ์ƒ์„ฑ

package com.hastagram.myapp.users.model;

import org.springframework.web.multipart.MultipartFile;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString(exclude = "profileData")
public class UserImgsVO {
	
	private int userImgNo;
	private int userNo;
	private String profileName;
	private long profileSize;
	private String profileContentType;
	private byte[] profileData;
	
	private MultipartFile file;
}

 

ํ”„๋กœํ•„ ์‚ฌ์ง„ ํšŒ์› ๋ชจ๋ธ์— ํ”„๋กœํ•„ ์‚ฌ์ง„ ์ •๋ณด๋„ ๊ฐ™์ด ๋‹ด์„๊นŒ ์ƒ๊ฐํ–ˆ์ง€๋งŒ ํ”„๋กœํ•„ ์‚ฌ์ง„์ด ์—†๋Š” ํšŒ์›์ด ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ ํšŒ์› ํ”„๋กœํ•„ ์‚ฌ์ง„ ๋ชจ๋ธ์„ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ๋‹ค.

 

LoginVO ๋กœ๊ทธ์ธ ์‹œ๋„ํ•˜๋Š” ํšŒ์› ์ •๋ณด ๋‹ด์•„๋†“๋Š” ๋ชจ๋ธ

package com.hastagram.myapp.users.model;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class LoginVO {

	private String email;		//๋กœ๊ทธ์ธ ์‹œ๋„ ์ด๋ฉ”์ผ
	private String pw;		//๋กœ๊ทธ์ธ ์‹œ๋„ ๋น„๋ฐ€๋ฒˆํ˜ธ
}

 

Lombok ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ -> setter, getter, toString ๋“ฑ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ด์ฃผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ, ํ•„๋“œ๋งŒ ์ถ”๊ฐ€ํ•ด๋†“์œผ๋ฉด ๋œ๋‹ค. pom.xml์— lombok ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋‹ค์šด ๋ฐ›์•„์„œ ์‚ฌ์šฉ

<!-- lombok ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋‹ค์šด๋กœ๋“œ -->	
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.8</version>
    <scope>provided</scope>
</dependency>

 

 

 

Repository


IUsersDAO

package com.hastagram.myapp.users.repository;

import com.hastagram.myapp.users.model.LoginVO;
import com.hastagram.myapp.users.model.UserImgsVO;
import com.hastagram.myapp.users.model.UsersVO;

public interface IUsersDAO {

	/*************** ํšŒ์›๊ฐ€์ž… ๋กœ์ง ***************/
	//ํšŒ์› ๊ฐ€์ž… ์ฒ˜๋ฆฌ
	void register(UsersVO user) throws Exception;
	
	//์ด๋ฉ”์ผ ์ค‘๋ณตํ™•์ธ ์ฒ˜๋ฆฌ
	int isDuplicateEmail(String email) throws Exception;

	//์•„์ด๋”” ์ค‘๋ณตํ™•์ธ ์ฒ˜๋ฆฌ
	int isDuplicateId(String id) throws Exception;
	
	
	/*************** ๋กœ๊ทธ์ธ ๋กœ์ง ***************/
	//๋กœ๊ทธ์ธ ์‹œ๋„ ํšŒ์›์ •๋ณด ์กฐํšŒ ์ฒ˜๋ฆฌ
	UsersVO login(LoginVO login) throws Exception;
	
	
	/*************** ํšŒ์› ์ •๋ณด ๋กœ์ง ***************/
	//ํšŒ์› ์ •๋ณด ์ˆ˜์ •
	void modifyInfo(UsersVO user) throws Exception;
	
	//์ฒจ๋ถ€ํŒŒ์ผ์„ DB์—์„œ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
	UserImgsVO getProfile(int userNo) throws Exception;
	
	//ํ”„๋กœํ•„ ์‚ฌ์ง„ ๋“ฑ๋ก
	void insertUserImg(UserImgsVO file) throws Exception;
	
	//์•„์ด๋””๋กœ ํšŒ์›์˜ ๋ชจ๋“  ์ •๋ณด ์กฐํšŒ
	UsersVO inquiryOfUserById(String id) throws Exception;
	//์œ ์ €๋ฒˆํ˜ธ๋กœ ํšŒ์›์˜ ๋ชจ๋“  ์ •๋ณด ์กฐํšŒ
	UsersVO inquiryOfUserByUserNo(int userNo) throws Exception;
	
	//ํ”„๋กœํ•„ ์‚ฌ์ง„ ์‚ญ์ œ
	void deleteUserImg(int userNo) throws Exception;
	
	//๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ
	void modifyPw(UsersVO user) throws Exception;
	
	//ํšŒ์› ํƒˆํ‡ด
	void withdrawal(UsersVO user) throws Exception;
	
	
	
}

 

์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ƒ์„ฑํ•ด์„œ ์„ธ์…˜ํ…œํ”Œ๋ฆฟ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๋งคํผ ์ „์ฒด๋ฅผ ๊ตฌํ˜„ ํด๋ž˜์Šค๋กœ ์‚ฌ์šฉํ•˜๋„๋ก ํ•˜์˜€๋‹ค.

ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์€ ๊ธฐ๋Šฅ๋“ค์„ ๋งŒ๋“ค๋ฉด์„œ ์ถ”๊ฐ€ํ•˜์˜€๋‹ค. ํšŒ์›๊ฐ€์ž…๊ณผ ๋กœ๊ทธ์ธ ๋กœ์ง์€ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ ํšŒ์›์ •๋ณด ๋กœ์ง์—์„œ ๊ทธ๋•Œ๋งˆ๋‹ค ํ•„์š”ํ•œ ๊ธฐ๋Šฅ๋“ค์„ ์ถ”๊ฐ€ํ•˜๋‹ค๋ณด๋‹ˆ ์‚ด์ง ๋ณต์žกํ•ด์ง„ ๊ฒƒ๊ฐ™์€ ๋Š๋‚Œ. ํ”„๋กœํ•„ ์‚ฌ์ง„ ์ฒ˜๋ฆฌํ•˜๋Š”๊ฒŒ ์ œ์ผ ๊ณจ์น˜๊ฐ€ ์•„ํŒ ์Œ.

  • ํšŒ์›๊ฐ€์ž… ๋กœ์ง - ํšŒ์›๊ฐ€์ž…, ์ด๋ฉ”์ผ ์ค‘๋ณตํ™•์ธ, ์•„์ด๋”” ์ค‘๋ณตํ™•์ธ
  • ๋กœ๊ทธ์ธ ๋กœ์ง - ๋กœ๊ทธ์ธ ์‹œ๋„ํ•œ ํšŒ์›์˜ ์ •๋ณด ์กฐํšŒ
  • ํšŒ์›์ •๋ณด ๋กœ์ง - ํšŒ์›์ •๋ณด ์ˆ˜์ •, ์ฒจ๋ถ€ํŒŒ์ผ db์—์„œ ์กฐํšŒ, ํ”„๋กœํ•„ ์‚ฌ์ง„ ๋“ฑ๋ก, ์•„์ด๋””๋กœ ํšŒ์›์ •๋ณด ์กฐํšŒ, ์œ ์ €๋ฒˆํ˜ธ๋กœ ํšŒ์›์ •๋ณด ์กฐํšŒ, ํ”„๋กœํ•„ ์‚ฌ์ง„ ์‚ญ์ œ, ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ, ํšŒ์› ํƒˆํ‡ด

 

 

Mapper


UsersMapper

<?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.hastagram.myapp.users.repository.IUsersDAO">
	
	<!-- UserResultMap ์„ค์ • -->
	<resultMap type="com.hastagram.myapp.users.model.UsersVO" id="UsersResultMap">
		<!-- primary key๋Š” idํƒœ๊ทธ -->
		<id property="userNo" column="user_no" />
		<!-- ๋‚˜๋จธ์ง€๋Š” resultํƒœ๊ทธ -->
		<result property="email" column="email"/>
		<result property="id" column="id"/>
		<result property="pw" column="pw"/>
		<result property="name" column="name"/>
		<result property="intro" column="intro"/>
		<result property="phone" column="phone"/>
		<result property="regDate" column="regDate"/>
		
		<result property="profileName" column="profile_name" />
		<result property="profileSize" column="profile_size" />
		<result property="profileContentType" column="profile_content_type" />
		<result property="fileData" column="file_data" />
	</resultMap>
	
	<resultMap type="com.hastagram.myapp.users.model.UserImgsVO" id="UserImgsResultMap">
 		<id property="userImgNo" column="user_img_no" />
 		<result property="userNo" column="user_no" />
 		<result property="profileName" column="profile_name" />
 		<result property="profileSize" column="profile_size" />
 		<result property="profileContentType" column="profile_content_type" />
 		<result property="profileData" column="profile_data" />
 	</resultMap>
 	
 	
 	<!-- ///////////////////// ํšŒ์›๊ฐ€์ž… ๋กœ์ง ///////////////////// -->
 	<!-- ํšŒ์› ๋“ฑ๋ก SQL -->
	<insert id="register">
		insert into users(email, id, pw, name) values(#{email}, #{id}, #{pw}, #{name})
	</insert>
	
	<!-- ์ด๋ฉ”์ผ ์ค‘๋ณตํ™•์ธ SQL -->
	<select id="isDuplicateEmail" resultType="int">
		select count(*) 
		from users 
		where email=#{email}
	</select>
	
	<!-- ์•„์ด๋”” ์ค‘๋ณตํ™•์ธ SQL -->
	<select id="isDuplicateId" resultType="int">
		select count(*) 
		from users 
		where id=#{id}
	</select>
	
	
	
	<!-- ///////////////////// ๋กœ๊ทธ์ธ ๋กœ์ง ///////////////////// -->
	<!-- ํšŒ์›์ •๋ณด ์กฐํšŒ ๋™์  SQL ์ฒ˜๋ฆฌ -->
	<select id="login" resultMap="UsersResultMap">
		select 
			U.user_no as user_no, 
		    email, 
		    id, 
		    pw, 
		    name, 
		    intro, 
		    phone, 
		    reg_date, 
		    I.user_img_no as user_img_no, 
		    I.profile_name as profile_name, 
		    I.profile_size as porfile_size, 
		    I.profile_content_type as profile_content_type 
		from users U 
		left outer join user_imgs I 
		on U.user_no = I.user_no 
		where email=#{email}
	</select>
	
	

	<!-- ///////////////////// ํšŒ์› ์ •๋ณด ๋กœ์ง ///////////////////// -->
	<!-- ํšŒ์› ์ •๋ณด ์ˆ˜์ • ๊ธฐ๋Šฅ -->
	<update id="modifyInfo">
		update users set id=#{id}, email=#{email}, name=#{name}, intro=#{intro}, phone=#{phone} where user_no=#{userNo}
	</update>
	
	<!-- ํŒŒ์ผ ์กฐํšŒ ๊ธฐ๋Šฅ -->
	<select id="getProfile" resultMap="UserImgsResultMap">
		select * from user_imgs where user_no=#{userNo}
	</select>
	
	<!-- ํ”„๋กœํ•„ ์‚ฌ์ง„ ๋“ฑ๋ก ๊ธฐ๋Šฅ -->
	<insert id="insertUserImg">
		insert into user_imgs (user_no, profile_name, profile_size, profile_content_type, profile_data) values (#{userNo}, #{profileName}, #{profileSize}, #{profileContentType}, #{profileData})
	</insert>
	
	<!-- ์•„์ด๋””๋กœ ํšŒ์› ๋ชจ๋“  ์ •๋ณด ์กฐํšŒ ๊ธฐ๋Šฅ -->
	<select id="inquiryOfUserById" resultMap="UsersResultMap">
		select 
			U.user_no as user_no, 
		    email, 
		    id, 
		    pw, 
		    name, 
		    intro, 
		    phone, 
		    reg_date, 
		    I.user_img_no as user_img_no, 
		    I.profile_name as profile_name, 
		    I.profile_size as porfile_size, 
		    I.profile_content_type as profile_content_type 
		from users U 
		left outer join user_imgs I 
		on U.user_no = I.user_no 
		where id=#{id};
	</select>
	
	<!-- ํšŒ์› ๋ฒˆํ˜ธ๋กœ ํšŒ์› ๋ชจ๋“  ์ •๋ณด ์กฐํšŒ ๊ธฐ๋Šฅ -->
	<select id="inquiryOfUserByUserNo" resultMap="UsersResultMap">
		select 
			U.user_no as user_no, 
		    email, 
		    id, 
		    pw, 
		    name, 
		    intro, 
		    phone, 
		    reg_date, 
		    I.user_img_no as user_img_no, 
		    I.profile_name as profile_name, 
		    I.profile_size as porfile_size, 
		    I.profile_content_type as profile_content_type 
		from users U 
		left outer join user_imgs I 
		on U.user_no = I.user_no 
		where U.user_no=#{userNo};
	</select>
	
	<!-- ํ”„๋กœํ•„ ํŒŒ์ผ ์‚ญ์ œ -->
	<delete id="deleteUserImg">
		delete from user_imgs where user_no = #{userNo}
	</delete>
	
	<!-- ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ ๊ธฐ๋Šฅ -->
	<update id="modifyPw">
		update users set pw=#{pw} where user_no=#{userNo}
	</update>
	
	<!-- ํšŒ์› ํƒˆํ‡ด ๊ธฐ๋Šฅ -->
	<delete id="withdrawal">
		delete from users where user_no=#{userNo}
	</delete>
	
</mapper>

๋งคํผ ์ž‘์„ฑ

๊ตฌํ˜„ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์ง€ ์•Š๊ณ  ๋งคํผ.xml ํŒŒ์ผ ์ž์ฒด๋ฅผ ํด๋ž˜์Šค, ์ž๋ฐ”๊ฐ์ฒด๋กœ ์‚ฌ์šฉ. ๊ทธ๋ƒฅ ๋‘๋ฉด ์–˜๊ฐ€ ๊ตฌํ˜„ ํด๋ž˜์Šค์ธ์ค„ ๋ชจ๋ฅด๋‹ˆ๊นŒ ์ถ”๊ฐ€๋กœ mvc-config.xml ์—์„œ ์„ค์ •์„ ํ•ด์ฃผ์–ด์•ผํ•œ๋‹ค. 

<!-- [Mapper.xml ํŒŒ์ผ ๋นˆ๊ฐ์ฒด๋กœ ๋“ฑ๋ก (=@Repository)] -->
<mybatis-spring:scan base-package="com.hastagram.myapp.users.repository"/>

id์™€ ๋ฉ”์„œ๋“œ ๋ช…์„ ๋™์ผํ•˜๊ฒŒ ์ž‘์„ฑํ•  ๊ฒƒ. ResultMap ๋งŒ๋“ค๊ธฐ. ์—˜๋ฆฌ์•„์Šค ์ฒ˜๋ฆฌ๋Š” ์•ˆํ•ด๋„๋œ๋‹ค.

(๋‹ค๋ฅธ ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๋•Œ๋Š” ์—˜๋ฆฌ์•„์Šค ์ฒ˜๋ฆฌ๋ฅผ ํ–ˆ์—ˆ๋Š”๋ฐ ์ด๋ฒˆ์—” ์•ˆํ•ด๋„๋œ๋‹ค. why? type์— ์ „์ฒด ๊ฒฝ๋กœ๋ฅผ ์ ์–ด๋‘์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์—˜๋ฆฌ์•„์Šค ์„ค์ •์„ ์•ˆํ•ด๋„๋œ๋‹ค. ์—˜๋ฆฌ์•„์Šค->๊ธธ๊ฒŒ ์“ฐ๊ธฐ ๊ท€์ฐฎ์•„์„œ ๋ณ„์นญ์„ ์ง€์ •ํ•ด์ฃผ๋Š” ์กด์žฌ)

 

 

 

Test


JUnit Test

package com.hastagram.myapp.userstest;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.hastagram.myapp.users.model.LoginVO;
import com.hastagram.myapp.users.model.UsersVO;
import com.hastagram.myapp.users.repository.IUsersDAO;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations= {"classpath:/spring/mvc-config.xml"})
public class UsersDAOTest {

	@Autowired
	private IUsersDAO usersDAO;
	
	//ํšŒ์›๊ฐ€์ž… ํ…Œ์ŠคํŠธ
	@Test
	public void register() throws Exception {
		
		UsersVO user = new UsersVO();
		user.setEmail("qkqh@test.com");
		user.setId("qkqh");
		user.setPw("123123123!");
		
		usersDAO.register(user);
	}
	
	//์ด๋ฉ”์ผ ์ค‘๋ณตํ™•์ธ ํ…Œ์ŠคํŠธ
	@Test
	public void isEmail() throws Exception {
		
		int result = usersDAO.isDuplicateEmail("test@test.com");
		
		if(result == 1) {
			System.out.println("์ด๋ฉ”์ผ ์ค‘๋ณต!");
		} else {
			System.out.println("์ด๋ฉ”์ผ ์‚ฌ์šฉ ๊ฐ€๋Šฅ!");
		}
	}
	
	//์•„์ด๋”” ์ค‘๋ณตํ™•์ธ ํ…Œ์ŠคํŠธ
	@Test
	public void isId() throws Exception {
		
		int result = usersDAO.isDuplicateId("qkqh");
		
		if(result == 1) {
			System.out.println("์•„์ด๋”” ์ค‘๋ณต!");
		} else {
			System.out.println("์•„์ด๋”” ์‚ฌ์šฉ ๊ฐ€๋Šฅ!");
		}
	}
	
	//๋กœ๊ทธ์ธ ํ…Œ์ŠคํŠธ
	@Test
	public void login() throws Exception {
		
		//๋กœ๊ทธ์ธ vo์ƒ์„ฑ
		LoginVO login = new LoginVO();
		login.setEmail("qkqh@test.com");
		login.setPw("123123123!");
		
		//๋กœ๊ทธ์ธ ์‹œ๋„ํ•œ ํšŒ์›์˜ ๋ชจ๋“  ์ •๋ณด ๊บผ๋‚ด์˜ค๊ธฐ 
		UsersVO user = usersDAO.login(login);
		System.out.println("๋กœ๊ทธ์ธ ์‹œ๋„ ํšŒ์› ์ •๋ณด : " + user);
	}
	
	//ํšŒ์› ์ •๋ณด ์ˆ˜์ •
	@Test
	public void modifyInfo() throws Exception {
		
		UsersVO user = new UsersVO();
		user.setUserNo(1);
		user.setId("qkRNj");
		user.setEmail("gjgjgj@naver.com");
		user.setName("๋ฐ”๋ณด์”จ");
		user.setIntro("์•ˆ๋…•ํ•˜์‡ผ");
		user.setPhone("010-333-3333");
		
		usersDAO.modifyInfo(user);
	}
	
	//๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ •
	@Test
	public void updatePw() throws Exception {
		
		UsersVO user = new UsersVO();
		user.setUserNo(2);
		user.setPw("gkgkkkggkkgk");
		
		usersDAO.modifyPw(user);
	}
	
	//ํšŒ์› ํƒˆํ‡ด ํ…Œ์ŠคํŠธ
	@Test
	public void delelte() throws Exception {
		UsersVO user = new UsersVO();
		user.setUserNo(2);
		usersDAO.withdrawal(user);
	}

ํ…Œ์ŠคํŠธ๋Š” junit์œผ๋กœ ํ•˜์˜€๊ณ  user๊ธฐ๋Šฅ ๋ชจ๋‘ ๋ฌธ์ œ ์—†์ด ๋™์ž‘ํ–ˆ๋‹ค.

 

 

Service


IUsersService

package com.hastagram.myapp.users.service;

import com.hastagram.myapp.users.model.LoginVO;
import com.hastagram.myapp.users.model.UserImgsVO;
import com.hastagram.myapp.users.model.UsersVO;

public interface IUsersService {

	/*************** ํšŒ์›๊ฐ€์ž… ๋กœ์ง ***************/
	//ํšŒ์› ๊ฐ€์ž… ์ฒ˜๋ฆฌ
	void register(UsersVO user) throws Exception;
	
	//์ด๋ฉ”์ผ ์ค‘๋ณตํ™•์ธ ์ฒ˜๋ฆฌ
	int isDuplicateEmail(String email) throws Exception;
	
	//์•„์ด๋”” ์ค‘๋ณตํ™•์ธ ์ฒ˜๋ฆฌ
	int isDuplicateId(String id) throws Exception;
	
	
	/*************** ๋กœ๊ทธ์ธ ๋กœ์ง ***************/
	//๋กœ๊ทธ์ธ ์‹œ๋„ ํšŒ์›์ •๋ณด ์กฐํšŒ ์ฒ˜๋ฆฌ
	UsersVO login(LoginVO login) throws Exception;
	
	
	/*************** ํšŒ์› ์ •๋ณด ๋กœ์ง ***************/
	//ํšŒ์› ์ •๋ณด ์ˆ˜์ •
	void modifyInfo(UsersVO user) throws Exception;
	//์ฒจ๋ถ€ํŒŒ์ผ์„ DB์—์„œ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
	UserImgsVO getProfile(int userNo) throws Exception;
	//ํ”„๋กœํ•„ ์‚ฌ์ง„ ๋“ฑ๋ก
	void insertUserImg(UserImgsVO file) throws Exception;
	
	//์•„์ด๋””๋กœ ํšŒ์›์˜ ๋ชจ๋“  ์ •๋ณด ์กฐํšŒ
	UsersVO inquiryOfUserById(String id) throws Exception;
	//์œ ์ €๋ฒˆํ˜ธ๋กœ ํšŒ์›์˜ ๋ชจ๋“  ์ •๋ณด ์กฐํšŒ
	UsersVO inquiryOfUserByUserNo(int userNo) throws Exception;
	
	//ํ”„๋กœํ•„ ์‚ฌ์ง„ ์‚ญ์ œ
	void deleteUserImg(int userNo) throws Exception;
	//๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ
	void modifyPw(UsersVO user) throws Exception;
	
	//๋น„๋ฐ€๋ฒˆํ˜ธ ์ฐพ๊ธฐ
	String findPw(LoginVO login) throws Exception;
	
	//ํšŒ์› ํƒˆํ‡ด
	void withdrawal(UsersVO user) throws Exception;
}

์ธํ„ฐํŽ˜์ด์Šค ์ž‘์„ฑ ํ›„ ๊ตฌํ˜„ ํด๋ž˜์Šค UserService๋„ ์ƒ์„ฑ

 

 

 

Controller


UsersController

@RestController
@RequestMapping("/user")
public class UsersController {
	
	private static final Logger logger = LoggerFactory.getLogger(UsersController.class);
	
	@Autowired
	private IUsersService usersService;

Restfulํ•˜๊ฒŒ URI๋ฅผ ๊ตฌ์„ฑํ•˜๊ฒ ๋‹ค -> @RestController

๊ณตํ†ต URL @RequestMapping -> /user

๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€