Commit 5ef37b1f by 高晓磊

司机端用户增删改查--copy场站用户

parent 3e0e4d88
package com.beecode.inz.basis.config;
import com.beecode.inz.basis.dao.DriverUserDao;
import com.beecode.inz.basis.internal.dao.DriverUserDaoImpl;
import com.beecode.inz.basis.internal.service.DriverUserServiceImpl;
import com.beecode.inz.basis.service.DriverUserService;
import com.beecode.inz.basis.web.DriverUserController;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -60,6 +65,20 @@ public class CommonConfig {
public WarehouseUserController warehouseUserController() {
return new WarehouseUserController();
}
@Bean
public DriverUserService driverUserService() {
return new DriverUserServiceImpl();
}
@Bean
public DriverUserDao driverUserDao() {
return new DriverUserDaoImpl();
}
@Bean
public DriverUserController driverUserController() {
return new DriverUserController();
}
//采砂用户服务Bean
@Bean
......
package com.beecode.inz.basis.config.constants;
public class DriverUserConstants extends CommonBaseConst{
public static final String ENTITY = "com.beecode.inz.basis.datamodel.DriverUser";
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String ID_CARD = "idCard";
public static final String TYPE = "type";
public static final String ORG = "org";
public static final String PATH = "path";
public static final String ROLE = "role";
public static final String CONFIG = "config";
public static final String DESCRIPTION = "description";
public static final String TELEPHONE = "telephone";
public static final String ENABLED = "enabled";
public static final String TRANSPORT_COMPANY_ID = "transportCompanyId";
}
package com.beecode.inz.basis.dao;
import com.beecode.bcp.type.KObject;
import java.util.List;
import java.util.UUID;
public interface DriverUserDao extends BaseDao {
List<KObject> listByUserName(String username);
List<KObject> listByTelephone(String telephone);
KObject findByUsernameOrTelephone(String username);
List<KObject> findAllByTransportCompanyId(UUID transportCompanyId);
List<KObject> queryPositionByName(String phone);
List<KObject> userNameRepeatCheck(String username);
}
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.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;
import java.util.List;
import java.util.UUID;
@Repository
public class DriverUserDaoImpl extends AbstractBaseDao implements DriverUserDao {
@Autowired
private HibernateTemplate template;
public DriverUserDaoImpl(){
}
@Override
protected HibernateTemplate getHibernateTemplate() {
return template;
}
@Override
protected String getModelName() {
return DriverUserConstants.ENTITY;
}
@Override
public KObject findByUsernameOrTelephone(String username) {
return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer("FROM " + getModelName() + " WHERE (username = :username OR telephone = :username) AND enabled = 1 AND discard = 0 ");
//创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameter("username", username);
List<KObject> result = query.getResultList();
if(result != null && result.size() > 0) {
return result.get(0);
}
return null;
});
}
/**
* 获取运输公司所有用户
*/
@Override
public List<KObject> findAllByTransportCompanyId(UUID transportCompanyId) {
return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer("FROM " + getModelName() + " WHERE transportCompanyId = :transportCompanyId AND enabled = 1 AND discard = 0 ");
//创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameter("transportCompanyId", transportCompanyId);
return query.getResultList();
});
}
@Override
public List<KObject> listByUserName(String username) {
return listByAttributes(buildSingleMap(DriverUserConstants.USERNAME, username));
}
@Override
public List<KObject> listByTelephone(String telephone) {
return listByAttributes(buildSingleMap(DriverUserConstants.TELEPHONE, telephone));
}
@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);
query.setParameter("phone", phone);
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);
query.setParameter("username", username);
return query.getResultList();
});
}
}
package com.beecode.inz.basis.internal.service;
import com.beecode.amino.core.Amino;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.DriverUserConstants;
import com.beecode.inz.basis.dao.DriverUserDao;
import com.beecode.inz.basis.pojo.DriverUser;
import com.beecode.inz.basis.service.DriverUserService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.util.Assert;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* 砂场用户 service
* @author pengwufeng
*
*/
public class DriverUserServiceImpl implements DriverUserService {
//spring 密码加密工具类
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private DriverUserDao dao;
@Override
public DriverUser getById(UUID id) {
Assert.notNull(id, "'id' must be not null!");
KObject entity = dao.findById(id);
return DriverUser.fromKObject(entity);
}
@Override
public DriverUser getByUsernameOrTelephone(String userame) {
Assert.notNull(userame, "'userName' must be not null!");
KObject object = dao.findByUsernameOrTelephone(userame);
if (object != null) {
return DriverUser.fromKObject(object);
}
return null;
}
@Override
public DriverUser getByUsername(String userame) {
Assert.notNull(userame, "'userName' must be not null!");
List<KObject> list = dao.listByUserName(userame);
if (list != null && list.size() > 0) {
return DriverUser.fromKObject(list.get(0));
}
return null;
}
@Override
public DriverUser getByTelephone(String telephone) {
Assert.notNull(telephone, "'telephone' must be not null!");
List<KObject> list = dao.listByTelephone(telephone);
if (list != null && list.size() > 0) {
return DriverUser.fromKObject(list.get(0));
}
return null;
}
/**
* 获取指定运输公司下所有用户
* @param transportCompanyId
* @return
*/
@Override
public List<KObject> getAllByTransportCompanyId(UUID transportCompanyId) {
Assert.notNull(transportCompanyId, "'transportCompanyId' must be not null!");
List<KObject> list = dao.findAllByTransportCompanyId(transportCompanyId);
return list;
}
@Transactional
@Override
public UUID create(DriverUser driverUser) {
Assert.notNull(driverUser, "'driverUser' must be not null!");
Assert.notNull(driverUser.getUsername(), "'username' must be not null!");
Assert.notNull(driverUser.getTitle(), "'title' must be not null!");
Assert.notNull(driverUser.getIdCard(), "'idCard' must be not null!");
Assert.notNull(driverUser.getPassword(), "'password' must be not null!");
if(driverUser.getId() == null) {
driverUser.setId(UUID.randomUUID());
}
driverUser.setState("NORMAL");
driverUser.setEnabled(true);
driverUser.setCreator(AminoContextHolder.getContext().getStaff());
if (driverUser.getCreateTime() == null) {
driverUser.setCreateTime(new Date());
}
//密码加密
driverUser.setPassword(passwordEncoder.encode(driverUser.getPassword()));
return dao.insert(beanToObject(driverUser));
}
public KObject beanToObject(DriverUser driverUser){
KClass kclass = Amino.getApplicationMetadataContext().getBean(DriverUserConstants.ENTITY, KClass.class);
KObject obj = kclass.newInstance();
obj.set(DriverUserConstants.ID, driverUser.getId());
obj.set(DriverUserConstants.USERNAME, driverUser.getUsername());
obj.set(DriverUserConstants.PASSWORD, driverUser.getPassword());
obj.set(DriverUserConstants.TITLE, driverUser.getTitle());
obj.set(DriverUserConstants.ID_CARD, driverUser.getIdCard());
obj.set(DriverUserConstants.CODE, driverUser.getCode());
obj.set(DriverUserConstants.TYPE, driverUser.getType());
obj.set(DriverUserConstants.TELEPHONE, driverUser.getTelephone());
obj.set(DriverUserConstants.TRANSPORT_COMPANY_ID, driverUser.getTransportCompanyId());
obj.set(DriverUserConstants.ORG, driverUser.getOrg());
obj.set(DriverUserConstants.PATH, driverUser.getPath());
obj.set(DriverUserConstants.ROLE, driverUser.getRole());
obj.set(DriverUserConstants.CONFIG, driverUser.getConfig());
obj.set(DriverUserConstants.DESCRIPTION, driverUser.getDescription());
obj.set(DriverUserConstants.STATE, driverUser.getState());
obj.set(DriverUserConstants.ENABLED, driverUser.isEnabled());
obj.set(DriverUserConstants.CREATOR, driverUser.getCreator());
obj.set(DriverUserConstants.CREATE_TIME, driverUser.getCreateTime());
obj.set(DriverUserConstants.MODIFIER, driverUser.getModifier());
obj.set(DriverUserConstants.MODIFY_TIME, driverUser.getModifyTime());
obj.set(DriverUserConstants.VERSION, driverUser.getVersion());
return obj;
}
@Transactional(rollbackOn = Exception.class)
@Override
public void modify(DriverUser driverUser) {
Assert.notNull(driverUser, "'driverUser' must be not null!");
Assert.notNull(driverUser.getId(), "'driverUser.id' must be not null!");
Assert.notNull(driverUser.getUsername(), "'driverUser.userName' must be not null!");
Assert.notNull(driverUser.getTitle(), "'driverUser.title' must be not null!");
Assert.notNull(driverUser.getIdCard(), "'idCard' must be not null!");
Assert.notNull(driverUser.getCreateTime(), "'driverUser.createTime' must be not null!");
KObject entity = dao.findById(driverUser.getId());
if(entity != null) {
//赋值,更新
if(StringUtils.isNotBlank(driverUser.getUsername())) {
entity.set(DriverUserConstants.USERNAME, driverUser.getUsername());
}
if(StringUtils.isNotBlank(driverUser.getTitle())) {
entity.set(DriverUserConstants.TITLE, driverUser.getTitle());
}
if(StringUtils.isNotBlank(driverUser.getTelephone())) {
entity.set(DriverUserConstants.TELEPHONE, driverUser.getTelephone());
}
if(StringUtils.isNotBlank(driverUser.getOrg())) {
entity.set(DriverUserConstants.ORG, driverUser.getOrg());
}
if(StringUtils.isNotBlank(driverUser.getPath())) {
entity.set(DriverUserConstants.PATH, driverUser.getPath());
}
if(StringUtils.isNotBlank(driverUser.getRole())) {
entity.set(DriverUserConstants.ROLE, driverUser.getRole());
}
if(StringUtils.isNotBlank(driverUser.getDescription())) {
entity.set(DriverUserConstants.DESCRIPTION, driverUser.getDescription());
}
if(StringUtils.isNotBlank(driverUser.getState())) {
entity.set(DriverUserConstants.STATE, driverUser.getState());
}
if(StringUtils.isNotBlank(driverUser.getConfig())) {
entity.set(DriverUserConstants.CONFIG, driverUser.getConfig());
}
if(driverUser.getModifier() != null) {
entity.set(DriverUserConstants.MODIFIER, driverUser.getModifier());
}
entity.set(DriverUserConstants.MODIFY_TIME, driverUser.getModifyTime());
dao.update(entity);
}
}
@Transactional
@Override
public void updatePassword(UUID id, String newPassword) {
Assert.notNull(id, "'id' must be not null!");
Assert.notNull(newPassword, "'newPassword' must be not null!");
KObject entity = dao.findById(id);
if(entity != null) {
//密码加密
entity.set(DriverUserConstants.PASSWORD, passwordEncoder.encode(newPassword));
dao.update(entity);
}
}
@Override
public Boolean phoneRepeatCheck(String phone) {
List<KObject> list = dao.queryPositionByName(phone);
Boolean flag = false;
if (list != null && list.size() > 0 ) {
flag = true;
}
return flag;
}
@Override
public Boolean userNameRepeatCheck(String username) {
List<KObject> list = dao.userNameRepeatCheck(username);
Boolean flag = false;
if (list != null && list.size() > 0 ) {
flag = true;
}
return flag;
}
}
package com.beecode.inz.basis.pojo;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.DriverUserConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.UUID;
/**
* @author pengwufeng
*
*/
public class DriverUser implements UserDetails, Serializable {
/**
*
*/
private static final long serialVersionUID = -553263854279399734L;
/**
* 用户ID
*/
private UUID id;
/**
* 版本号
*/
private Long version;
/**
* 登录名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 用户名称
*/
private String title;
/**
* 身份证号
*/
private String idCard;
/**
* 客户编码
*/
private String code;
/**
* 客户类型
*/
private String type;
/**
* 手机号
*/
private String telephone;
/**
* 所属场站id
*/
private UUID transportCompanyId;
/**
* 所属组织
*/
private String org;
/**
* 组织路径
*/
private String path;
/**
* 所属角色
*/
private String role;
/**
* 用户配置
*/
private String config;
/**
* 描述
*/
private String description;
/**
* 状态
*/
private String state;
/**
* 是否可用
*/
private Boolean enabled;
/**
* 创建人
*/
private KObject creator;
/**
* 创建日期
*/
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss")
private Date createTime;
/**
* 修改日期
*/
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss")
private Date modifyTime;
/**
* 修改人
*/
private KObject modifier;
public DriverUser() {
}
public static DriverUser fromKObject(KObject object) {
try {
DriverUser model = new DriverUser();
model.setId(object.getUuid(DriverUserConstants.ID));
model.setVersion(object.getLong(DriverUserConstants.VERSION));
model.setUsername(object.getString(DriverUserConstants.USERNAME));
model.setPassword(object.getString(DriverUserConstants.PASSWORD));
model.setTitle(object.getString(DriverUserConstants.TITLE));
model.setIdCard(object.getString(DriverUserConstants.ID_CARD));
model.setCode(object.getString(DriverUserConstants.CODE));
model.setType(object.getString(DriverUserConstants.TYPE));
model.setTelephone(object.getString(DriverUserConstants.TELEPHONE));
model.setTransportCompanyId(object.getUuid(DriverUserConstants.TRANSPORT_COMPANY_ID));
model.setOrg(object.getString(DriverUserConstants.ORG));
model.setPath(object.getString(DriverUserConstants.PATH));
model.setRole(object.getString(DriverUserConstants.ROLE));
model.setDescription(object.getString(DriverUserConstants.DESCRIPTION));
model.setState(object.getString(DriverUserConstants.STATE));
model.setConfig(object.getString(DriverUserConstants.CONFIG));
model.setEnabled(object.getBoolean(DriverUserConstants.ENABLED));
model.setCreateTime(object.getDate(DriverUserConstants.CREATE_TIME));
model.setCreator(object.get(DriverUserConstants.MODIFIER).isNull() ? null : object.get(DriverUserConstants.CREATOR));
model.setModifyTime(object.getDate(DriverUserConstants.MODIFY_TIME));
model.setModifier(object.get(DriverUserConstants.MODIFIER).isNull() ? null : object.get(DriverUserConstants.MODIFIER));
return model;
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return new ArrayList<SimpleGrantedAuthority>();
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return !getEnabled();
}
@Override
public boolean isCredentialsNonExpired() {
return false;
}
@Override
public boolean isEnabled() {
return this.enabled != null ? this.enabled : false ;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
public UUID getTransportCompanyId() {
return transportCompanyId;
}
public void setTransportCompanyId(UUID transportCompanyId) {
this.transportCompanyId = transportCompanyId;
}
public String getOrg() {
return org;
}
public void setOrg(String org) {
this.org = org;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public KObject getCreator() {
return creator;
}
public void setCreator(KObject creator) {
this.creator = creator;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public KObject getModifier() {
return modifier;
}
public void setModifier(KObject modifier) {
this.modifier = modifier;
}
}
package com.beecode.inz.basis.service;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.pojo.DriverUser;
import java.util.List;
import java.util.UUID;
/**
* Service
* @author pengwufeng
*
*/
public interface DriverUserService {
/**
* 创建客户
* @param driverUser
* @return
*/
UUID create(DriverUser driverUser);
/**
* 根据电话获取客户
* @param telephone
* @return
*/
DriverUser getByTelephone(String telephone);
/**
* 根据用户名获取客户
* @param userame
* @return
*/
DriverUser getByUsername(String userame);
/**
* 根据id获取客户
* @param userame
* @return
*/
DriverUser getById(UUID id);
DriverUser getByUsernameOrTelephone(String userame);
/**
* 根据传参对每个字段进行识别更新,不包含id,code,createtime,version等字段
* @param driverUser
*/
void modify(DriverUser driverUser);
/**
* 更新指定客户的密码
* @param id
* @param newPassword
*/
void updatePassword(UUID id, String newPassword);
/**
* 获取指定运输公司下所有用户
* @param transportCompanyId
* @return
*/
List<KObject> getAllByTransportCompanyId(UUID transportCompanyId);
Boolean phoneRepeatCheck(String parameter);
Boolean userNameRepeatCheck(String parameter);
}
package com.beecode.inz.basis.web;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.pojo.DriverUser;
import com.beecode.inz.basis.service.DriverUserService;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.basis.util.JsonUtil;
import com.beecode.xlib.json.JSONException;
import com.beecode.xlib.json.JSONObject;
import com.beecode.xlib.runtime.Assert;
import com.beecode.xlib.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.UUID;
/**
* 运输公司用户controller
* @author pengwufeng
*
*/
@RestController
public class DriverUserController {
private static final Logger logger = LoggerFactory.getLogger(DriverUserController.class);
@Autowired
private DriverUserService driverUserService;
@Autowired
private HttpServletRequest request;
/**
* 创建运输公司用户
* @param obj
* @return
*/
@PostMapping("/driverUser")
public Object create(@RequestBody String body) {
if(StringUtil.isEmpty(body)) {
return ResponseObj.error("参数不能为空");
}
DriverUser driverUser = JsonUtil.jsonToBean(body, DriverUser.class);
if(driverUser == null) {
return ResponseObj.error("参数无法识别");
}
try {
driverUserService.create(driverUser);
} catch(Exception e) {
logger.error("", e);
return ResponseObj.error(e.getMessage());
}
return ResponseObj.success("操作成功",null);
}
/**
* 创建运输公司用户
* @return
*/
@GetMapping("/driver/user/transportCompany/{transportCompanyId}")
public Object getByTransportCompanyId(@PathVariable(name="transportCompanyId") String transportCompanyId) {
if(StringUtil.isEmpty(transportCompanyId)) {
return ResponseObj.error("transportCompanyId不能为空");
}
try {
UUID id = UUID.fromString(transportCompanyId);
List<KObject> list = driverUserService.getAllByTransportCompanyId(id);
return ResponseObj.success("操作成功", list);
} catch (IllegalArgumentException e) {
return ResponseObj.error("transportCompanyId错误");
} catch (Exception e) {
return ResponseObj.error("操作失败");
}
}
/**
* 根据id查询用户
* @param obj
* @return
*/
@GetMapping("/driver/user/queryById/{id}")
public Object queryById(@PathVariable(name="id") String id) {
if(StringUtil.isEmpty(id)) {
return ResponseObj.error("id不能为空");
}
try {
DriverUser driverUser = driverUserService.getById(UUID.fromString(id));
return ResponseObj.success("操作成功", driverUser);
} catch (IllegalArgumentException e) {
return ResponseObj.error("transportCompanyId错误");
} catch (Exception e) {
return ResponseObj.error("操作失败");
}
}
/**
* 编辑
* @param obj
* @return
*/
@PostMapping("/driver/user/modify")
public Object modify(@RequestBody String body) {
if(StringUtil.isEmpty(body)) {
return ResponseObj.error("参数不能为空");
}
DriverUser driverUser = JsonUtil.jsonToBean(body, DriverUser.class);
if(driverUser == null) {
return ResponseObj.error("参数无法识别");
}
try {
driverUserService.modify(driverUser);
} catch(Exception e) {
logger.error("", e);
return ResponseObj.error(e.getMessage());
}
return ResponseObj.success("操作成功",null);
}
/**
* 验证状态
* @return
* @throws Exception
*/
@RequestMapping(value ="/driver/api/login/status",method = RequestMethod.GET)
public String loginState(){
return Integer.toString(HttpStatus.OK.value());
}
/**
* 用户名,手机号校验重复
*
* @param obj
* @return
*/
@ResponseBody
@RequestMapping(value = "/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;
JSONObject object;
try {
object = new JSONObject(body);
parameter = object.optString("parameter",null);
} catch (JSONException e) {
e.printStackTrace();
}
switch (operation) {
case "PHONE_CHECK":
// 手机号重复查询 true为重复
Boolean phoneResult = driverUserService.phoneRepeatCheck(parameter);
if(phoneResult){
return ResponseObj.error("手机号码重复");
}
case "USERNAME_CHECK":
Boolean userNameResult = driverUserService.userNameRepeatCheck(parameter);
if(userNameResult){
return ResponseObj.error("账号重复");
}
default:
return null;
}
}
}
<model>
<header>
<type>bcp.type.DataModel</type>
<package>com.beecode.inz.basis.datamodel</package>
<title>司机用户</title>
<name>DriverUser</name>
<tags></tags>
<description></description>
<templateName>mk.ide.ui.editor.data.model.template.common</templateName>
<tablePrefix>xyst_dinas_</tablePrefix>
</header>
<content>
<dataModel id='f49d88ed-7bac-47cc-8f7f-6b88128b6a47' multiVersion='undefined' domainInherit='undefined' tableName='xyst_dinas_basis_driver_user'>
<attribute id='d95c9da0-84df-4675-b35b-d9fdaa15ba04' name='id' columnName='id' title='id' type='uuid' default='' precision='' isArray='false'>
<annotation id='df3e380a-974d-4c27-976a-02c0088dbefb' attributeId='b06eae4f-5e8d-4137-9162-a94df665e420'
name='length' value='undefined'/>
<annotation id='6a53fd2c-0598-4752-ad64-d332343881ab' attributeId='b516046b-6130-4f11-9874-150a40dfb192'
name='unique' value='false'/>
</attribute>
<attribute id='bd2373f4-0c29-4b57-ba34-88f24e07aeb8' name='username' columnName='username' title='用户名' type='string' default='' precision='' isArray='false'>
<annotation id='8a45f4db-c3a9-446e-bfc9-d9104f44acd5' attributeId='89b07d00-c725-4005-a237-31cc55e66255'
name='length' value='50'/>
</attribute>
<attribute id='d6c5fccd-3255-4cd8-a09c-e0e17d89c4d9' name='password' columnName='password' title='密码' type='string' default='' precision='' isArray='false'>
<annotation id='e3350c9d-567c-4736-be4b-73a8d728f687' attributeId='cddf40e4-1c67-46aa-83c9-909853c72611'
name='length' value='100'/>
</attribute>
<attribute id='706bda9e-1a68-4a3f-858b-861bdd89c776' name='title' columnName='title' title='称呼' type='string' default='' precision='' isArray='false'>
<annotation id='786ad90c-a2a2-4c4a-9ce1-3749a42cceb1' attributeId='737e0eea-65db-44e0-8f7f-61e9f9ae1771'
name='length' value='100'/>
</attribute>
<attribute id='f9c8067e-4e13-4546-b469-f664514b1140' name='code' columnName='code' title='编号' type='string' default='' precision='' isArray='false'>
<annotation id='8549c009-5ce2-45fe-af96-2bb8717565bb' attributeId='0c3a8cbf-a558-4054-87c0-55dcdce5425e'
name='length' value='100'/>
</attribute>
<attribute id='fd595860-de4e-42f1-81a2-e917cf467ef6' name='type' columnName='type' title='用户类型' type='string' default='' precision='' isArray='false'>
<annotation id='60a99dd7-c48f-430c-9a4b-37e27fbbcd34' attributeId='42c68547-71ce-4b52-8359-c899cce93897'
name='length' value='100'/>
</attribute>
<attribute id='70ca3fe7-2146-4f60-a848-ad42e4503ffa' name='telephone' columnName='telephone' title='手机号' type='string' default='' precision='' isArray='false'>
<annotation id='f8c8ef3f-9e1c-4dee-be79-0cb1d377536b' attributeId='af0856b6-b2dc-44e1-8fb0-abc8738f5096'
name='length' value='20'/>
</attribute>
<attribute id='a0f0a77e-61ed-440f-bf0c-ba339711fe1c' name='idCard' columnName='id_card' title='身份证' type='string' default='' precision='' isArray='false'>
<annotation id='e97dc7c1-9ee4-40f8-af92-fc41eb07f18f' attributeId='404b2eb6-6cbb-4c4d-abff-53607803e891'
name='length' value='30'/>
</attribute>
<attribute id='2bce7596-f7eb-4455-83cf-dd6b0d93a3ee' name='transportCompanyId' columnName='transport_company_id' title='所属运输公司id' type='uuid' default='' precision='' isArray='false'>
<annotation id='7ca7b001-475c-4d6b-9e91-4e5724dbc056' attributeId='d3b4f056-d1e4-4369-9dda-30d9b509f217'
name='length' value='undefined'/>
</attribute>
<attribute id='9b9afb49-209e-4115-85e5-c56c8c77b23f' name='org' columnName='org' title='所属组织' type='string' default='' precision='' isArray='false'>
<annotation id='e6f87a52-7af4-4e92-94fa-096d8a462ce8' attributeId='a394aacc-559a-42ac-b8e8-09d9dcf8eacb'
name='length' value='100'/>
</attribute>
<attribute id="480c8656-79c7-480d-822a-7069df7ba443" name="path" columnName='path' title="组织路径" type="string" default="" precision="" isArray="false">
<annotation name="length" value="300" id="4c38d4ce-a485-4159-8240-4c329887b1c7" attributeId="8f8ad8bf-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id='a7467bd2-00d5-4c74-bc9c-92b4fa6617a8' name='role' columnName='role' title='所属角色' type='string' default='' precision='' isArray='false'>
<annotation id='1cc84699-61a2-4526-a863-62eba6372352' attributeId='01a30605-1b91-41f5-bf88-da3c4266f9b1'
name='length' value='100'/>
</attribute>
<attribute id='82e038bd-c816-48e2-bc8e-1ba8089ab03d' name='config' columnName='config' title='用户配置' type='string' default='' precision='' isArray='false'>
<annotation id='9b6394de-5cd9-466c-af39-0e47d8e1dfe4' attributeId='ad08c1e9-fed7-43b6-ae55-14186de63d36'
name='length' value='1000'/>
</attribute>
<attribute id='4a849984-5db0-49a5-b955-4e2baae637e1' name='description' columnName='description' title='描述' type='string' default='' precision='' isArray='false'>
<annotation id='6205c25a-b5fe-4d77-85a8-1440ea9835a5' attributeId='01a17165-a5fd-4835-b684-963982322d62'
name='length' value='1000'/>
</attribute>
<attribute id='80cdf43a-f0c8-4298-854c-94ef7e95c26b' name='state' columnName='state' title='状态' type='string' default='' precision='' isArray='false'>
<annotation id='db64f06c-0785-42ba-a41c-0821d537d5a1' attributeId='eccc2e6d-ba2b-47f9-af74-9d8cafca7d11'
name='length' value='50'/>
</attribute>
<attribute id="c9ad0e76-baf3-4786-9009-7eeaeadcd5bd" name="discard" title="是否废弃" type="boolean" default="false" precision="" isArray="false">
<annotation name="length" value="undefined" id="e3e74a0f-e00b-4053-9c19-4bdf5c4e2872" attributeId="243bc8be-7d1b-4eaf-880d-58e4a8860d2e"/>
</attribute>
<attribute id="0d6f607e-c610-4756-952b-921d1a390605" name="enabled" title="是否启用" type="boolean" default="false" precision="" isArray="false">
<annotation name="length" value="undefined" id="73505e20-fe1f-4de7-8346-8a2ea3ea7e29" attributeId="6bb62c5d-0396-4056-bd1a-3269cda4ee06"/>
</attribute>
<attribute id="8ac6d22a-8c75-4a0b-9c63-5a2c395fcb87" name="version" title="version" type="int" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="3d53af60-c18c-4ef0-9ffb-759544fd29a8" attributeId="4248e11c-f581-44cd-9ff1-d485ed83f6c9"/>
</attribute>
<attribute id="84c9421e-22b0-47b5-9053-fe1cea95b3d8" name="creator" title="创建人" type="com.beecode.bap.staff.datamodel.Staff" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="d86e226f-7c8a-4245-aecb-6b957141255c" attributeId="c904fda7-8063-4a1d-9704-6dae78eb8d34"/>
</attribute>
<attribute id="a777a502-5825-427b-898d-dd745653b3ea" name="createTime" columnName='create_time' title="创建时间" type="datetime" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="1451cae4-21bd-4e74-948d-9ac5f7221572" attributeId="61c03024-1f82-41f5-9433-351db111fa41"/>
</attribute>
<attribute id="66f27467-3b44-4f42-9847-26114e8a3b80" name="modifyTime" columnName='modify_time' title="最后修改时间" type="datetime" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="60273301-22b3-4e9a-90e2-c63900d346b1" attributeId="2c8bdfbc-14ec-4c45-8998-a9b0541b7dff"/>
</attribute>
<attribute id="fd8dbf84-853e-11eb-b258-54ee750ba9b2" name="modifier" title="修改人" type="com.beecode.bap.staff.datamodel.Staff" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="9cb62cff-da38-49cd-a3db-ef801438c361" attributeId="2a2da0f7-ee02-431a-9329-a69b663b273c"/>
</attribute>
<hibernate>/inz.basis/src/main/resources/config/DriverUser.hbm.xml</hibernate>
</dataModel>
</content>
</model>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping
http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd">
<class entity-name="com.beecode.inz.basis.datamodel.DriverUser" table="xyst_dinas_basis_driver_user" optimistic-lock="version">
<tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary">
<column name="id" length="16"/>
<generator class="uuid2" />
</id>
<version name="version" type="long" column="version"></version>
<property name="username" type="string" >
<column name="username" length="50" unique="true"></column>
</property>
<property name="password" type="string" >
<column name="password" length="100"></column>
</property>
<property name="title" type="string" >
<column name="title" length="100"></column>
</property>
<property name="code" type="string" >
<column name="code" length="100" unique="true"></column>
</property>
<property name="type" type="string" >
<column name="type" length="100"></column>
</property>
<property name="telephone" type="string" >
<column name="telephone" length="20"></column>
</property>
<property name="transportCompanyId" type="uuid-binary" >
<column name="transport_company_id" length="16"></column>
</property>
<property name="org" type="string" >
<column name="org" length="100"></column>
</property>
<property name="path" type="string" >
<column name="path" length="100"></column>
</property>
<property name="role" type="string" >
<column name="role" length="100"></column>
</property>
<property name="config" type="text" >
<column name="config"></column>
</property>
<property name="description" type="text">
<column name="description" />
</property>
<property name="state" type="string" >
<column name="state" length="50"></column>
</property>
<property name="discard" type="boolean" >
<column name="discard" />
</property>
<property name="enabled" type="boolean" >
<column name="enabled" />
</property>
<property name="createTime" type="timestamp">
<column name="create_time" />
</property>
<many-to-one name="creator" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="creator_id" not-null="false"/>
</many-to-one>
<property name="modifyTime" type="timestamp">
<column name="modify_time" />
</property>
<many-to-one name="modifier" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="modifier_id" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
\ No newline at end of file
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