Commit c36c1c2a by 高晓磊

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

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