Commit c3d8ff70 authored by ranjun's avatar ranjun

user dao

parent 9f33d9f2
...@@ -11,7 +11,9 @@ import org.springframework.http.MediaType; ...@@ -11,7 +11,9 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
@RestController @RestController
@RequestMapping("/user") @RequestMapping("/user")
...@@ -46,6 +48,12 @@ public class UserController { ...@@ -46,6 +48,12 @@ public class UserController {
@RequestMapping(value = "/update", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/update", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Object updateUser(){//@RequestBody UserDto userDto public Object updateUser(){//@RequestBody UserDto userDto
UserDto userDto = new UserDto(); UserDto userDto = new UserDto();
userDto.setTuId(11l);
List<Long> longs = new ArrayList<>();
longs.add(1l);
longs.add(11l);
longs.add(111l);
userDto.setRoleIds(longs);
userDto.setUserName("test11234111"); userDto.setUserName("test11234111");
userDto.setPassword("12345612"); userDto.setPassword("12345612");
userDto.setPhoneNumber("123456789110"); userDto.setPhoneNumber("123456789110");
......
...@@ -56,7 +56,8 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao { ...@@ -56,7 +56,8 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao {
Table.add(GET_USER, "SELECT p.* FROM pd_user p WHERE 1=1 ") Table.add(GET_USER, "SELECT p.* FROM pd_user p WHERE 1=1 ")
.add("username", " AND p.user_name = ?"); .add("username", " AND p.user_name = ?");
Table.add(DELETE_USER_ROLE,"delete from pd_user_role_relation where tu_id = ?"); Table.add(DELETE_USER_ROLE,"delete from pd_user_role_relation where 1=1")
.add("tu_id","and tu_id = ?");
} }
...@@ -68,14 +69,20 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao { ...@@ -68,14 +69,20 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao {
@Override @Override
public int deleteUserRole(UserRoleRelation userRoleRelation) { public int deleteUserRole(UserRoleRelation userRoleRelation) {
return this.updateSql(DELETE_USER_ROLE,userRoleRelation); userRoleRelation.setTru_id(1l);
if (userRoleRelation.getTu_id()!=null) {
return this.updateSql(DELETE_USER_ROLE, userRoleRelation);
}else{
return 0;
}
} }
@Override @Override
public int saveUserRoles(List<UserRoleRelation> userRoleRelations) { public int saveUserRoles(List<UserRoleRelation> userRoleRelations) {
//this.create(userRoleRelations);
for (UserRoleRelation userRoleRelation : userRoleRelations) { for (UserRoleRelation userRoleRelation : userRoleRelations) {
this.create(userRoleRelation); //this.save(userRoleRelation);
} }
return userRoleRelations.size(); return 0;
} }
} }
...@@ -54,6 +54,8 @@ public class UserServiceImpl implements UserService { ...@@ -54,6 +54,8 @@ public class UserServiceImpl implements UserService {
if (userDto.getRoleIds()!=null&&userDto.getRoleIds().size()!=0) { if (userDto.getRoleIds()!=null&&userDto.getRoleIds().size()!=0) {
List<Long> longs = userDto.getRoleIds();//多个角色 List<Long> longs = userDto.getRoleIds();//多个角色
List<UserRoleRelation> userRoleRelations = new ArrayList<>(); List<UserRoleRelation> userRoleRelations = new ArrayList<>();
//查询当前用户的ID
//UserVo userVo = userDao.getUser(userDto);
for (Long l : longs) { for (Long l : longs) {
UserRoleRelation userRoleRelation = new UserRoleRelation(); UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setTr_id(l); userRoleRelation.setTr_id(l);
......
...@@ -4,8 +4,11 @@ import com.yanzuoguang.dao.TableAnnotation; ...@@ -4,8 +4,11 @@ import com.yanzuoguang.dao.TableAnnotation;
@TableAnnotation("pd_user_role_relation") @TableAnnotation("pd_user_role_relation")
public class UserRoleRelation { public class UserRoleRelation {
@TableAnnotation("tru_id")
private Long tru_id; private Long tru_id;
@TableAnnotation("tr_id")
private Long tr_id; private Long tr_id;
@TableAnnotation("tu_id")
private Long tu_id; private Long tu_id;
public Long getTru_id() { public Long getTru_id() {
......
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