Commit 8a01518d authored by 李博今's avatar 李博今

完善优雅修改

parent e202df87
...@@ -6,6 +6,7 @@ import com.qiqiim.webserver.base.dao.BaseDao; ...@@ -6,6 +6,7 @@ import com.qiqiim.webserver.base.dao.BaseDao;
import com.qiqiim.webserver.user.model.ConsultantManagerEntity; import com.qiqiim.webserver.user.model.ConsultantManagerEntity;
import com.qiqiim.webserver.user.model.UserAccountEntity; import com.qiqiim.webserver.user.model.UserAccountEntity;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface UserAccountDao extends BaseDao<UserAccountEntity> { public interface UserAccountDao extends BaseDao<UserAccountEntity> {
...@@ -30,4 +31,19 @@ public interface UserAccountDao extends BaseDao<UserAccountEntity> { ...@@ -30,4 +31,19 @@ public interface UserAccountDao extends BaseDao<UserAccountEntity> {
public int updateConsultantName(@Param(value = "name") String name, @Param(value = "id") long id); public int updateConsultantName(@Param(value = "name") String name, @Param(value = "id") long id);
public int updateConsultantMessagePhone(@Param(value = "messagePhone") String messagePhone, @Param(value = "id") long id); public int updateConsultantMessagePhone(@Param(value = "messagePhone") String messagePhone, @Param(value = "id") long id);
@Update(
"<script>" +
"update user_info,user_account set " +
"<if test=\"deptName !=null and deptName != '' \">user_info.deptid = #{deptName}, </if> " +
"<if test=\"password !=null and password != '' \">user_account.password = #{password}, </if> " +
"<if test=\"remark !=null and remark != '' \">user_info.remark = #{remark}, </if> " +
"<if test=\"phone !=null and phone != '' \">user_info.phone = #{phone}, </if> " +
"<if test=\"name !=null and name != '' \">user_info.name = #{name}, </if> " +
"<if test=\"messagePhone !=null and messagePhone != '' \">user_info.message_phone = #{messagePhone}, </if> " +
"user_info.uid = #{id} " +
"where user_info.uid = #{id} and user_info.uid = user_account.id" +
"</script>"
)
public int updateConsultant(ConsultantManagerEntity consultantManagerEntity);
} }
...@@ -169,4 +169,5 @@ ...@@ -169,4 +169,5 @@
<update id="updateConsultantMessagePhone"> <update id="updateConsultantMessagePhone">
update user_info set message_phone = #{messagePhone} where uid = #{id} update user_info set message_phone = #{messagePhone} where uid = #{id}
</update> </update>
</mapper> </mapper>
\ No newline at end of file
...@@ -16,7 +16,6 @@ import com.qiqiim.webserver.user.service.UserAccountService; ...@@ -16,7 +16,6 @@ import com.qiqiim.webserver.user.service.UserAccountService;
import com.qiqiim.webserver.user.service.UserInfoService; import com.qiqiim.webserver.user.service.UserInfoService;
@Service("userAccountServiceImpl") @Service("userAccountServiceImpl")
public class UserAccountServiceImpl implements UserAccountService { public class UserAccountServiceImpl implements UserAccountService {
@Autowired @Autowired
...@@ -27,34 +26,34 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -27,34 +26,34 @@ public class UserAccountServiceImpl implements UserAccountService {
private UserAdminInfoServiceImpl userAdminInfoService; private UserAdminInfoServiceImpl userAdminInfoService;
@Override @Override
public UserAccountEntity queryObject(Long id){ public UserAccountEntity queryObject(Long id) {
return userAccountDao.queryObject(id); return userAccountDao.queryObject(id);
} }
@Override @Override
public List<UserAccountEntity> queryList(Map<String, Object> map){ public List<UserAccountEntity> queryList(Map<String, Object> map) {
return userAccountDao.queryList(map); return userAccountDao.queryList(map);
} }
@Override @Override
public int queryTotal(Map<String, Object> map){ public int queryTotal(Map<String, Object> map) {
return userAccountDao.queryTotal(map); return userAccountDao.queryTotal(map);
} }
@Override @Override
public int save(UserAccountEntity userAccount){ public int save(UserAccountEntity userAccount) {
//判断用户是否已注册 //判断用户是否已注册
Map<String,Object> map = new HashMap<String,Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("account", userAccount.getAccount()); map.put("account", userAccount.getAccount());
UserAccountEntity user = queryObjectByAccount(map); UserAccountEntity user = queryObjectByAccount(map);
if(user==null||user.getId()<1){ if (user == null || user.getId() < 1) {
userAccountDao.save(userAccount); userAccountDao.save(userAccount);
if(userAccount!=null&&userAccount.getId()!=null){ if (userAccount != null && userAccount.getId() != null) {
//保存基本信息 //保存基本信息
UserInfoEntity userInfo = userAccount.getUserInfo(); UserInfoEntity userInfo = userAccount.getUserInfo();
userInfo.setUid(userAccount.getId()); userInfo.setUid(userAccount.getId());
userInfoServiceImpl.save(userInfo); userInfoServiceImpl.save(userInfo);
if(userAccount.getUserInfo().getDeptid() != 2){ if (userAccount.getUserInfo().getDeptid() != 2) {
userAdminInfoService.save(userAccount.getId()); userAdminInfoService.save(userAccount.getId());
} }
return 1; return 1;
...@@ -64,17 +63,17 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -64,17 +63,17 @@ public class UserAccountServiceImpl implements UserAccountService {
} }
@Override @Override
public int update(UserAccountEntity userAccount){ public int update(UserAccountEntity userAccount) {
return userAccountDao.update(userAccount); return userAccountDao.update(userAccount);
} }
@Override @Override
public int delete(Long id){ public int delete(Long id) {
return userAccountDao.delete(id); return userAccountDao.delete(id);
} }
@Override @Override
public int deleteBatch(Long[] ids){ public int deleteBatch(Long[] ids) {
return userAccountDao.deleteBatch(ids); return userAccountDao.deleteBatch(ids);
} }
...@@ -86,13 +85,13 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -86,13 +85,13 @@ public class UserAccountServiceImpl implements UserAccountService {
@Override @Override
public List<ConsultantManagerEntity> getAllConsultant(Long deptId) { public List<ConsultantManagerEntity> getAllConsultant(Long deptId) {
String tiaojian = ""; String tiaojian = "";
if(deptId == 1L){ if (deptId == 1L) {
tiaojian = " deptid = 1"; tiaojian = " deptid = 1";
}else if(deptId == 3L){ } else if (deptId == 3L) {
tiaojian = " deptid = 3"; tiaojian = " deptid = 3";
}else if(deptId == 4L){ } else if (deptId == 4L) {
tiaojian = " deptid = 4"; tiaojian = " deptid = 4";
}else{ } else {
tiaojian = " deptid != 2"; tiaojian = " deptid != 2";
} }
return userAccountDao.getAllConsultant(tiaojian); return userAccountDao.getAllConsultant(tiaojian);
...@@ -101,24 +100,26 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -101,24 +100,26 @@ public class UserAccountServiceImpl implements UserAccountService {
@Override @Override
public int updateDetail(ConsultantManagerEntity consultantManagerEntity) throws UnsupportedEncodingException { public int updateDetail(ConsultantManagerEntity consultantManagerEntity) throws UnsupportedEncodingException {
int i = 0; int i = 0;
if(consultantManagerEntity.getDeptName() != null && !"".equals(consultantManagerEntity.getDeptName())){ consultantManagerEntity.setName(new String(consultantManagerEntity.getName().getBytes("iso8859-1"), "UTF-8"));
i += userAccountDao.updateConsultantDept( new String (consultantManagerEntity.getDeptName().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId())); // if(consultantManagerEntity.getDeptName() != null && !"".equals(consultantManagerEntity.getDeptName())){
} // i += userAccountDao.updateConsultantDept( new String (consultantManagerEntity.getDeptName().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId()));
if (consultantManagerEntity.getPassword() != null && !"".equals(consultantManagerEntity.getPassword())){ // }
i += userAccountDao.updateConsultantPassword( new String (consultantManagerEntity.getPassword().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId())); // if (consultantManagerEntity.getPassword() != null && !"".equals(consultantManagerEntity.getPassword())){
} // i += userAccountDao.updateConsultantPassword( new String (consultantManagerEntity.getPassword().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId()));
if(consultantManagerEntity.getName() != null && !"".equals(consultantManagerEntity.getName())){ // }
i += userAccountDao.updateConsultantName( new String (consultantManagerEntity.getName().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId())); // if(consultantManagerEntity.getName() != null && !"".equals(consultantManagerEntity.getName())){
} // i += userAccountDao.updateConsultantName( new String (consultantManagerEntity.getName().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId()));
if(consultantManagerEntity.getPhone() != null){ // }
i += userAccountDao.updateConsultantPhone( new String (consultantManagerEntity.getPhone().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId())); // if(consultantManagerEntity.getPhone() != null){
} // i += userAccountDao.updateConsultantPhone( new String (consultantManagerEntity.getPhone().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId()));
if(consultantManagerEntity.getRemark() != null){ // }
i += userAccountDao.updateConsultantRemark( new String (consultantManagerEntity.getRemark().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId())); // if(consultantManagerEntity.getRemark() != null){
} // i += userAccountDao.updateConsultantRemark( new String (consultantManagerEntity.getRemark().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId()));
if(consultantManagerEntity.getMessagePhone() != null){ // }
i += userAccountDao.updateConsultantMessagePhone( new String (consultantManagerEntity.getMessagePhone().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId())); // if(consultantManagerEntity.getMessagePhone() != null){
} // i += userAccountDao.updateConsultantMessagePhone( new String (consultantManagerEntity.getMessagePhone().getBytes("iso8859-1"),"UTF-8"), Long.parseLong(consultantManagerEntity.getId()));
// }
i = userAccountDao.updateConsultant(consultantManagerEntity);
return i; return i;
} }
...@@ -130,9 +131,9 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -130,9 +131,9 @@ public class UserAccountServiceImpl implements UserAccountService {
@Override @Override
public UserAccountEntity validateUser(Map<String, Object> map) { public UserAccountEntity validateUser(Map<String, Object> map) {
UserAccountEntity user = queryObjectByAccount(map); UserAccountEntity user = queryObjectByAccount(map);
if(user!=null){ if (user != null) {
String password = (String)map.get("password"); String password = (String) map.get("password");
if(password.equals(user.getPassword())){ if (password.equals(user.getPassword())) {
return user; return user;
} }
} }
......
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