Commit c36c1c2a by 高晓磊

司机用户增加额外路径,避免与手机端冲突.添加修改时的校验.修改driverId的获取方式

parent 2fd6bb61
...@@ -15,9 +15,9 @@ public interface DriverUserDao extends BaseDao { ...@@ -15,9 +15,9 @@ public interface DriverUserDao extends BaseDao {
List<KObject> findAllByTransportCompanyId(UUID transportCompanyId); List<KObject> findAllByTransportCompanyId(UUID transportCompanyId);
List<KObject> queryPositionByName(String phone); List<KObject> queryPositionByName(String phone, String id);
List<KObject> userNameRepeatCheck(String username); List<KObject> userNameRepeatCheck(String username, String id);
List<KObject> idCardRepeatCheck(String idCard); List<KObject> idCardRepeatCheck(String idCard, String id);
} }
...@@ -3,11 +3,9 @@ package com.beecode.inz.basis.internal.dao; ...@@ -3,11 +3,9 @@ package com.beecode.inz.basis.internal.dao;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.DriverUserConstants; import com.beecode.inz.basis.config.constants.DriverUserConstants;
import com.beecode.inz.basis.dao.DriverUserDao; import com.beecode.inz.basis.dao.DriverUserDao;
import org.hibernate.HibernateException; import org.apache.commons.lang.StringUtils;
import org.hibernate.Session;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -74,27 +72,46 @@ public class DriverUserDaoImpl extends AbstractBaseDao implements DriverUserDao ...@@ -74,27 +72,46 @@ public class DriverUserDaoImpl extends AbstractBaseDao implements DriverUserDao
} }
@Override @Override
public List<KObject> queryPositionByName(String phone) { public List<KObject> queryPositionByName(String phone, String id) {
if(StringUtils.isEmpty(id)){
id=UUID.randomUUID().toString();
}
String hql = "from " + DriverUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and telephone =:phone and id != :id";
String finalId = id;
return template.execute(session -> { return template.execute(session -> {
Query<KObject> query = session.createQuery("from " + DriverUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and telephone =:phone ", KObject.class); Query<KObject> query = session.createQuery(hql, KObject.class);
query.setParameter("phone", phone); query.setParameter("phone", phone);
query.setParameter("id", UUID.fromString(finalId));
return query.getResultList(); return query.getResultList();
}); });
} }
@Override @Override
public List<KObject> userNameRepeatCheck(String username) { public List<KObject> userNameRepeatCheck(String username, String id) {
String hql = "from " + DriverUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and username =:username and id != :id";
if(StringUtils.isEmpty(id)){
id=UUID.randomUUID().toString();
}
String finalId = id;
return template.execute(session -> { return template.execute(session -> {
Query<KObject> query = session.createQuery("from " + DriverUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and username =:username ", KObject.class); Query<KObject> query = session.createQuery(hql, KObject.class);
query.setParameter("username", username); query.setParameter("username", username);
query.setParameter("id", UUID.fromString(finalId));
return query.getResultList(); return query.getResultList();
}); });
} }
@Override @Override
public List<KObject> idCardRepeatCheck(String idCard) { public List<KObject> idCardRepeatCheck(String idCard, String id) {
if(StringUtils.isEmpty(id)){
id=UUID.randomUUID().toString();
}
String finalId = id;
return template.execute(session -> { return template.execute(session -> {
Query<KObject> query = session.createQuery("from " + DriverUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and idCard =:idCard ", KObject.class); Query<KObject> query = session.createQuery("from " + DriverUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and idCard =:idCard and id != :id", KObject.class);
query.setParameter("idCard", idCard); query.setParameter("idCard", idCard);
query.setParameter("id", UUID.fromString(finalId));
return query.getResultList(); return query.getResultList();
}); });
} }
......
...@@ -203,8 +203,8 @@ public class DriverUserServiceImpl implements DriverUserService { ...@@ -203,8 +203,8 @@ public class DriverUserServiceImpl implements DriverUserService {
} }
@Override @Override
public Boolean phoneRepeatCheck(String phone) { public Boolean phoneRepeatCheck(String phone, String id) {
List<KObject> list = dao.queryPositionByName(phone); List<KObject> list = dao.queryPositionByName(phone,id);
Boolean flag = false; Boolean flag = false;
if (list != null && list.size() > 0 ) { if (list != null && list.size() > 0 ) {
flag = true; flag = true;
...@@ -213,8 +213,8 @@ public class DriverUserServiceImpl implements DriverUserService { ...@@ -213,8 +213,8 @@ public class DriverUserServiceImpl implements DriverUserService {
} }
@Override @Override
public Boolean userNameRepeatCheck(String username) { public Boolean userNameRepeatCheck(String username, String id) {
List<KObject> list = dao.userNameRepeatCheck(username); List<KObject> list = dao.userNameRepeatCheck(username,id);
Boolean flag = false; Boolean flag = false;
if (list != null && list.size() > 0 ) { if (list != null && list.size() > 0 ) {
flag = true; flag = true;
...@@ -223,8 +223,8 @@ public class DriverUserServiceImpl implements DriverUserService { ...@@ -223,8 +223,8 @@ public class DriverUserServiceImpl implements DriverUserService {
} }
@Override @Override
public Boolean idCardRepeatCheck(String idCard) { public Boolean idCardRepeatCheck(String idCard, String id) {
List<KObject> list = dao.idCardRepeatCheck(idCard); List<KObject> list = dao.idCardRepeatCheck(idCard,id);
Boolean flag = false; Boolean flag = false;
if (list != null && list.size() > 0 ) { if (list != null && list.size() > 0 ) {
flag = true; flag = true;
......
...@@ -149,7 +149,7 @@ public class DriverUser implements UserDetails, Serializable { ...@@ -149,7 +149,7 @@ public class DriverUser implements UserDetails, Serializable {
model.setTelephone(object.getString(DriverUserConstants.TELEPHONE)); model.setTelephone(object.getString(DriverUserConstants.TELEPHONE));
model.setTransportCompanyId(object.getUuid(DriverUserConstants.TRANSPORT_COMPANY_ID)); model.setTransportCompanyId(object.getUuid(DriverUserConstants.TRANSPORT_COMPANY_ID));
model.setOrg(object.getString(DriverUserConstants.ORG)); model.setOrg(object.getString(DriverUserConstants.ORG));
model.setDriverId(object.getString(DriverUserConstants.DRIVERID)); model.setDriverId(object.getString(DriverUserConstants.ID));
model.setPath(object.getString(DriverUserConstants.PATH)); model.setPath(object.getString(DriverUserConstants.PATH));
model.setRole(object.getString(DriverUserConstants.ROLE)); model.setRole(object.getString(DriverUserConstants.ROLE));
model.setDescription(object.getString(DriverUserConstants.DESCRIPTION)); model.setDescription(object.getString(DriverUserConstants.DESCRIPTION));
......
...@@ -63,11 +63,11 @@ public interface DriverUserService { ...@@ -63,11 +63,11 @@ public interface DriverUserService {
*/ */
List<KObject> getAllByTransportCompanyId(UUID transportCompanyId); List<KObject> getAllByTransportCompanyId(UUID transportCompanyId);
Boolean phoneRepeatCheck(String parameter); Boolean phoneRepeatCheck(String parameter, String id);
Boolean userNameRepeatCheck(String parameter); Boolean userNameRepeatCheck(String parameter, String id);
Boolean idCardRepeatCheck(String idCard); Boolean idCardRepeatCheck(String idCard, String id);
String getTransportCompanyNameByDriverUser(DriverUser driverUser); String getTransportCompanyNameByDriverUser(DriverUser driverUser);
} }
...@@ -63,10 +63,10 @@ public class DriverUserController { ...@@ -63,10 +63,10 @@ public class DriverUserController {
} }
/** /**
* 创建运输公司用户 * 根据运输公司id获取所有运输人员
* @return * @return
*/ */
@GetMapping("/driver/user/transportCompany/{transportCompanyId}") @GetMapping("/transportCompany/driver/user/transportCompany/{transportCompanyId}")
public Object getByTransportCompanyId(@PathVariable(name="transportCompanyId") String transportCompanyId) { public Object getByTransportCompanyId(@PathVariable(name="transportCompanyId") String transportCompanyId) {
if(StringUtil.isEmpty(transportCompanyId)) { if(StringUtil.isEmpty(transportCompanyId)) {
return ResponseObj.error("transportCompanyId不能为空"); return ResponseObj.error("transportCompanyId不能为空");
...@@ -89,7 +89,7 @@ public class DriverUserController { ...@@ -89,7 +89,7 @@ public class DriverUserController {
* @param obj * @param obj
* @return * @return
*/ */
@GetMapping("/driver/user/queryById/{id}") @GetMapping({"/driver/user/queryById/{id}","/transportCompany/driver/user/queryById/{id}"})
public Object queryById(@PathVariable(name="id") String id) { public Object queryById(@PathVariable(name="id") String id) {
if(StringUtil.isEmpty(id)) { if(StringUtil.isEmpty(id)) {
return ResponseObj.error("id不能为空"); return ResponseObj.error("id不能为空");
...@@ -109,7 +109,7 @@ public class DriverUserController { ...@@ -109,7 +109,7 @@ public class DriverUserController {
* @param obj * @param obj
* @return * @return
*/ */
@PostMapping("/driver/user/modify") @PostMapping({"/driver/user/modify","/transportCompany/driver/user/modify"})
public Object modify(@RequestBody String body) { public Object modify(@RequestBody String body) {
if(StringUtil.isEmpty(body)) { if(StringUtil.isEmpty(body)) {
return ResponseObj.error("参数不能为空"); return ResponseObj.error("参数不能为空");
...@@ -147,33 +147,35 @@ public class DriverUserController { ...@@ -147,33 +147,35 @@ public class DriverUserController {
* @return * @return
*/ */
@ResponseBody @ResponseBody
@RequestMapping(value = "/driver/user/verify", method = RequestMethod.PUT) @RequestMapping(value = {"/driver/user/verify","/transportCompany/driver/user/verify",}, method = RequestMethod.PUT)
public Object verify(@RequestBody String body){ public Object verify(@RequestBody String body){
Assert.notNull(body, "The body must not be null"); Assert.notNull(body, "The body must not be null");
String operation = request.getHeader("operation"); String operation = request.getHeader("operation");
Assert.notNull(operation, "'operation' must not be null"); Assert.notNull(operation, "'operation' must not be null");
String parameter = null; String parameter = null;
String id = null;
JSONObject object; JSONObject object;
try { try {
object = new JSONObject(body); object = new JSONObject(body);
parameter = object.optString("parameter",null); parameter = object.getString("parameter");
id = object.getString("id");
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
switch (operation) { switch (operation) {
case "PHONE_CHECK": case "PHONE_CHECK":
// 手机号重复查询 true为重复 // 手机号重复查询 true为重复
Boolean phoneResult = driverUserService.phoneRepeatCheck(parameter); Boolean phoneResult = driverUserService.phoneRepeatCheck(parameter,id);
if(phoneResult){ if(phoneResult){
return ResponseObj.error("手机号码重复"); return ResponseObj.error("手机号码重复");
} }
case "USERNAME_CHECK": case "USERNAME_CHECK":
Boolean userNameResult = driverUserService.userNameRepeatCheck(parameter); Boolean userNameResult = driverUserService.userNameRepeatCheck(parameter,id);
if(userNameResult){ if(userNameResult){
return ResponseObj.error("账号重复"); return ResponseObj.error("账号重复");
} }
case "ID_CARD_CHECK": case "ID_CARD_CHECK":
Boolean idCardResult = driverUserService.idCardRepeatCheck(parameter); Boolean idCardResult = driverUserService.idCardRepeatCheck(parameter,id);
if(idCardResult){ if(idCardResult){
return ResponseObj.error("身份证号重复"); return ResponseObj.error("身份证号重复");
} }
...@@ -188,7 +190,7 @@ public class DriverUserController { ...@@ -188,7 +190,7 @@ public class DriverUserController {
* @param obj * @param obj
* @return * @return
*/ */
@RequestMapping(value = "/driverUser/updatePassword", method = RequestMethod.POST) @RequestMapping(value = {"/driverUser/updatePassword","/transportCompany/driverUser/updatePassword",}, method = RequestMethod.POST)
public Object updatePassword(@RequestBody String content) { public Object updatePassword(@RequestBody String content) {
Map<String, Object> map = JSONObjectUtils.toMap(content); Map<String, Object> map = JSONObjectUtils.toMap(content);
if (null == map || map.size() == 0) if (null == map || map.size() == 0)
......
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