Commit 469e247a by PWF-WK01\pengwufeng

砂厂用户登出以及创建用户url调整

parent 5da02a78
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID"> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID">
<display-name>inz.war</display-name> <display-name>inz.platform.war</display-name>
<welcome-file-list> <welcome-file-list>
<welcome-file>index.html</welcome-file> <welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file> <welcome-file>index.htm</welcome-file>
......
...@@ -254,7 +254,7 @@ public class SecurityConfig { ...@@ -254,7 +254,7 @@ public class SecurityConfig {
http.csrf().disable(); http.csrf().disable();
http.cors().disable(); http.cors().disable();
http.antMatcher("/warehouse/**").authorizeRequests() http.antMatcher("/warehouse/**").authorizeRequests()
.antMatchers("/warehouse/user").permitAll() // .antMatchers("/warehouse/user").permitAll()
.anyRequest().authenticated(); .anyRequest().authenticated();
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint); http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
...@@ -266,8 +266,8 @@ public class SecurityConfig { ...@@ -266,8 +266,8 @@ public class SecurityConfig {
http.addFilterAfter(contextPersistenceFilter, SecurityContextPersistenceFilter.class); http.addFilterAfter(contextPersistenceFilter, SecurityContextPersistenceFilter.class);
http.addFilterAfter(new INZTenantAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class); http.addFilterAfter(new INZTenantAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
http.logout().logoutUrl("/logout") http.logout().logoutUrl("/warehouse/logout")
.addLogoutHandler(logoutHandler).invalidateHttpSession(true) .addLogoutHandler(logoutHandler).invalidateHttpSession(true)
.permitAll(); .permitAll();
} }
......
...@@ -5,6 +5,7 @@ public interface WarehouseUserConstants extends CommonConstants{ ...@@ -5,6 +5,7 @@ public interface WarehouseUserConstants extends CommonConstants{
String USERNAME = "username"; String USERNAME = "username";
String PASSWORD = "password"; String PASSWORD = "password";
String TYPE = "type"; String TYPE = "type";
String STATION_ID = "stationId";
String ORG = "org"; String ORG = "org";
String PATH = "path"; String PATH = "path";
String ROLE = "role"; String ROLE = "role";
......
...@@ -38,7 +38,7 @@ public class WarehouseUserServiceImpl implements WarehouseUserService { ...@@ -38,7 +38,7 @@ public class WarehouseUserServiceImpl implements WarehouseUserService {
public WarehouseUser getById(UUID id) { public WarehouseUser getById(UUID id) {
Assert.notNull(id, "'id' must be not null!"); Assert.notNull(id, "'id' must be not null!");
KObject entity = dao.findById(id); KObject entity = dao.findById(id);
return WarehouseUser.fromCustomerKObject(entity); return WarehouseUser.fromKObject(entity);
} }
@Override @Override
...@@ -46,7 +46,7 @@ public class WarehouseUserServiceImpl implements WarehouseUserService { ...@@ -46,7 +46,7 @@ public class WarehouseUserServiceImpl implements WarehouseUserService {
Assert.notNull(userame, "'userName' must be not null!"); Assert.notNull(userame, "'userName' must be not null!");
KObject object = dao.findByUsernameOrTelephone(userame); KObject object = dao.findByUsernameOrTelephone(userame);
if (object != null) { if (object != null) {
return WarehouseUser.fromCustomerKObject(object); return WarehouseUser.fromKObject(object);
} }
return null; return null;
} }
...@@ -56,21 +56,32 @@ public class WarehouseUserServiceImpl implements WarehouseUserService { ...@@ -56,21 +56,32 @@ public class WarehouseUserServiceImpl implements WarehouseUserService {
Assert.notNull(userame, "'userName' must be not null!"); Assert.notNull(userame, "'userName' must be not null!");
List<KObject> list = dao.listByUserName(userame); List<KObject> list = dao.listByUserName(userame);
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
return WarehouseUser.fromCustomerKObject(list.get(0)); return WarehouseUser.fromKObject(list.get(0));
} }
return null; return null;
} }
@Transactional
@Override @Override
public WarehouseUser getByTelephone(String telephone) { public WarehouseUser getByTelephone(String telephone) {
Assert.notNull(telephone, "'telephone' must be not null!"); Assert.notNull(telephone, "'telephone' must be not null!");
List<KObject> list = dao.listByTelephone(telephone); List<KObject> list = dao.listByTelephone(telephone);
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
return WarehouseUser.fromCustomerKObject(list.get(0)); return WarehouseUser.fromKObject(list.get(0));
} }
return null; return null;
} }
/**
* 获取指定场站下所有用户
* @param stationId
* @return
*/
@Override
public List<KObject> getAllByStationId(UUID stationId) {
Assert.notNull(stationId, "'stationId' must be not null!");
List<KObject> list = dao.findAllByStationId(stationId);
return list;
}
@Transactional @Transactional
@Override @Override
...@@ -108,6 +119,7 @@ public class WarehouseUserServiceImpl implements WarehouseUserService { ...@@ -108,6 +119,7 @@ public class WarehouseUserServiceImpl implements WarehouseUserService {
obj.set(WarehouseUserConstants.CODE, warehouseUser.getCode()); obj.set(WarehouseUserConstants.CODE, warehouseUser.getCode());
obj.set(WarehouseUserConstants.TYPE, warehouseUser.getType()); obj.set(WarehouseUserConstants.TYPE, warehouseUser.getType());
obj.set(WarehouseUserConstants.TELEPHONE, warehouseUser.getTelephone()); obj.set(WarehouseUserConstants.TELEPHONE, warehouseUser.getTelephone());
obj.set(WarehouseUserConstants.STATION_ID, warehouseUser.getStationId());
obj.set(WarehouseUserConstants.ORG, warehouseUser.getOrg()); obj.set(WarehouseUserConstants.ORG, warehouseUser.getOrg());
obj.set(WarehouseUserConstants.PATH, warehouseUser.getPath()); obj.set(WarehouseUserConstants.PATH, warehouseUser.getPath());
obj.set(WarehouseUserConstants.ROLE, warehouseUser.getRole()); obj.set(WarehouseUserConstants.ROLE, warehouseUser.getRole());
......
...@@ -65,6 +65,11 @@ public class WarehouseUser implements UserDetails, Serializable { ...@@ -65,6 +65,11 @@ public class WarehouseUser implements UserDetails, Serializable {
private String telephone; private String telephone;
/** /**
* 所属场站id
*/
private UUID stationId;
/**
* 所属组织 * 所属组织
*/ */
private String org; private String org;
...@@ -122,7 +127,7 @@ public class WarehouseUser implements UserDetails, Serializable { ...@@ -122,7 +127,7 @@ public class WarehouseUser implements UserDetails, Serializable {
} }
public static WarehouseUser fromCustomerKObject(KObject object) { public static WarehouseUser fromKObject(KObject object) {
try { try {
WarehouseUser model = new WarehouseUser(); WarehouseUser model = new WarehouseUser();
model.setId(object.getUuid(WarehouseUserConstants.ID)); model.setId(object.getUuid(WarehouseUserConstants.ID));
...@@ -133,6 +138,7 @@ public class WarehouseUser implements UserDetails, Serializable { ...@@ -133,6 +138,7 @@ public class WarehouseUser implements UserDetails, Serializable {
model.setCode(object.getString(WarehouseUserConstants.CODE)); model.setCode(object.getString(WarehouseUserConstants.CODE));
model.setType(object.getString(WarehouseUserConstants.TYPE)); model.setType(object.getString(WarehouseUserConstants.TYPE));
model.setTelephone(object.getString(WarehouseUserConstants.TELEPHONE)); model.setTelephone(object.getString(WarehouseUserConstants.TELEPHONE));
model.setStationId(object.getUuid(WarehouseUserConstants.STATION_ID));
model.setOrg(object.getString(WarehouseUserConstants.ORG)); model.setOrg(object.getString(WarehouseUserConstants.ORG));
model.setPath(object.getString(WarehouseUserConstants.PATH)); model.setPath(object.getString(WarehouseUserConstants.PATH));
model.setRole(object.getString(WarehouseUserConstants.ROLE)); model.setRole(object.getString(WarehouseUserConstants.ROLE));
...@@ -241,6 +247,14 @@ public class WarehouseUser implements UserDetails, Serializable { ...@@ -241,6 +247,14 @@ public class WarehouseUser implements UserDetails, Serializable {
this.telephone = telephone; this.telephone = telephone;
} }
public UUID getStationId() {
return stationId;
}
public void setStationId(UUID stationId) {
this.stationId = stationId;
}
public String getOrg() { public String getOrg() {
return org; return org;
} }
......
package com.beecode.inz.basis.service; package com.beecode.inz.basis.service;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.pojo.WarehouseUser; import com.beecode.inz.basis.pojo.WarehouseUser;
/** /**
...@@ -54,4 +56,11 @@ public interface WarehouseUserService { ...@@ -54,4 +56,11 @@ public interface WarehouseUserService {
*/ */
void updatePassword(UUID id, String newPassword); void updatePassword(UUID id, String newPassword);
/**
* 获取指定场站下所有用户
* @param stationId
* @return
*/
List<KObject> getAllByStationId(UUID stationId);
} }
package com.beecode.inz.basis.web; package com.beecode.inz.basis.web;
import java.util.List;
import java.util.UUID;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.beecode.bcp.core.context.AminoContextHolder; import com.beecode.bcp.core.context.AminoContextHolder;
...@@ -23,7 +27,6 @@ import com.beecode.xlib.utils.StringUtil; ...@@ -23,7 +27,6 @@ import com.beecode.xlib.utils.StringUtil;
* *
*/ */
@RestController @RestController
@RequestMapping("/warehouse/user")
public class WarehouseUserController { public class WarehouseUserController {
private static final Logger logger = LoggerFactory.getLogger(WarehouseUserController.class); private static final Logger logger = LoggerFactory.getLogger(WarehouseUserController.class);
...@@ -33,11 +36,10 @@ public class WarehouseUserController { ...@@ -33,11 +36,10 @@ public class WarehouseUserController {
/** /**
* 创建场站用户 * 创建场站用户
*
* @param obj * @param obj
* @return * @return
*/ */
@PostMapping @PostMapping("/warehouseuser")
public Object create(@RequestBody String body) { public Object create(@RequestBody String body) {
if(StringUtil.isEmpty(body)) { if(StringUtil.isEmpty(body)) {
return ResponseObj.error("参数不能为空"); return ResponseObj.error("参数不能为空");
...@@ -56,6 +58,29 @@ public class WarehouseUserController { ...@@ -56,6 +58,29 @@ public class WarehouseUserController {
return ResponseObj.success("操作成功",null); return ResponseObj.success("操作成功",null);
} }
/**
* 创建场站用户
* @param obj
* @return
*/
@GetMapping("/warehouse/user/station/{stationId}")
public Object getByStationId(@PathVariable(name="stationId") String stationId) {
if(StringUtil.isEmpty(stationId)) {
return ResponseObj.error("stationId不能为空");
}
try {
UUID id = UUID.fromString(stationId);
List<KObject> list = warehouseUserService.getAllByStationId(id);
return ResponseObj.success("操作成功", list);
} catch (IllegalArgumentException e) {
return ResponseObj.error("stationId错误");
} catch (Exception e) {
return ResponseObj.error("操作失败");
}
}
/** /**
* 创建场站用户 * 创建场站用户
...@@ -63,7 +88,7 @@ public class WarehouseUserController { ...@@ -63,7 +88,7 @@ public class WarehouseUserController {
* @param obj * @param obj
* @return * @return
*/ */
@PostMapping(value="test") @PostMapping(value="/warehouse/user/test")
public Object test(@RequestBody String body) { public Object test(@RequestBody String body) {
WarehouseUser user = WarehouseUserContextHolder.getContext().getWarehouseUser(); WarehouseUser user = WarehouseUserContextHolder.getContext().getWarehouseUser();
......
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