|
@@ -2,6 +2,7 @@ package com.zglc.fm.service;
|
|
|
|
|
|
import com.zglc.fm.entity.UserEntity;
|
|
import com.zglc.fm.entity.UserEntity;
|
|
import com.zglc.fm.dao.UserDao;
|
|
import com.zglc.fm.dao.UserDao;
|
|
|
|
+import com.zglc.fm.utils.DigestUtil;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.zglc.fm.base.Result;
|
|
import com.zglc.fm.base.Result;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
@@ -61,6 +62,11 @@ public class UserService {
|
|
}
|
|
}
|
|
|
|
|
|
public UserEntity getUser(Integer id) {
|
|
public UserEntity getUser(Integer id) {
|
|
|
|
+// if (id == 1) {
|
|
|
|
+// return null;
|
|
|
|
+// } else {
|
|
|
|
+// return userDao.selectByPrimaryKey(id);
|
|
|
|
+// }
|
|
return userDao.selectByPrimaryKey(id);
|
|
return userDao.selectByPrimaryKey(id);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -92,14 +98,16 @@ public class UserService {
|
|
public Result<String> addAndCheck(UserEntity data) {
|
|
public Result<String> addAndCheck(UserEntity data) {
|
|
boolean flag = true;
|
|
boolean flag = true;
|
|
String msg = "";
|
|
String msg = "";
|
|
- UserEntity tmpData = null;
|
|
|
|
Example example = new Example(UserEntity.class);
|
|
Example example = new Example(UserEntity.class);
|
|
- example.createCriteria().andEqualTo("id", data.getId());
|
|
|
|
- tmpData = userDao.selectOneByExample(example);
|
|
|
|
- if (tmpData != null) {
|
|
|
|
|
|
+ example.createCriteria().andEqualTo("userName", data.getUserName());
|
|
|
|
+ List<UserEntity> lst = userDao.selectByExample(example);
|
|
|
|
+ if (lst.size() > 0) {
|
|
flag = false;
|
|
flag = false;
|
|
msg = "用户已存在!";
|
|
msg = "用户已存在!";
|
|
} else {
|
|
} else {
|
|
|
|
+// UserEntity userEntity = new UserEntity();
|
|
|
|
+ String digestPassword = DigestUtil.getMD5Str(data.getPassword());
|
|
|
|
+ data.setPassword(digestPassword);
|
|
int index = userDao.insertSelective(data);
|
|
int index = userDao.insertSelective(data);
|
|
if (index == 0) {
|
|
if (index == 0) {
|
|
flag = false;
|
|
flag = false;
|
|
@@ -149,8 +157,8 @@ public class UserService {
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
Integer id = (Integer) iter.next();
|
|
Integer id = (Integer) iter.next();
|
|
UserEntity userEntity = userDao.selectByPrimaryKey(id);
|
|
UserEntity userEntity = userDao.selectByPrimaryKey(id);
|
|
- if (getImg(userEntity))
|
|
|
|
- files.add("image/" + userEntity.getImg());
|
|
|
|
|
|
+ if (getImg(userEntity))
|
|
|
|
+ files.add("image/" + userEntity.getImg());
|
|
int index = userDao.deleteByPrimaryKey(id);
|
|
int index = userDao.deleteByPrimaryKey(id);
|
|
if (index == 0) {
|
|
if (index == 0) {
|
|
flag = false;
|
|
flag = false;
|
|
@@ -176,5 +184,4 @@ public class UserService {
|
|
return Result.success(list);
|
|
return Result.success(list);
|
|
|
|
|
|
}
|
|
}
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
+}
|