Commit 0587e349 by kangxiaoshan

权限处理

parent 43e6bd00
...@@ -203,7 +203,12 @@ public class ContractController { ...@@ -203,7 +203,12 @@ public class ContractController {
@RequestMapping(value = "find/body", method = RequestMethod.GET) @RequestMapping(value = "find/body", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResultModel findBody(@CurrentAccount User loginAccount,@PathVariable String platform) { public ResultModel findBody(@CurrentAccount User loginAccount,@PathVariable String platform,String dropall) {
if("all".equals(dropall)){
platform = dropall;
}
return ResultModel.OK(service.findBody(platform)); return ResultModel.OK(service.findBody(platform));
} }
......
package common.controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.*;
@RestController
public class ContractSaveController {
@RequestMapping(value = "txt2db",method = RequestMethod.GET)
void saveTxtData2Db(){
BufferedReader reader = null;
try {
File txt = ResourceUtils.getFile("classpath:hisdata.txt");
reader = new BufferedReader(new FileReader(txt));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
// 显示行号
System.out.println(tempString);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
}
...@@ -62,6 +62,9 @@ public class LoginController { ...@@ -62,6 +62,9 @@ public class LoginController {
if(null != user.getRoleType()){ if(null != user.getRoleType()){
user.setRoleTypeName(roleTypeRepository.getName(user.getRoleType())); user.setRoleTypeName(roleTypeRepository.getName(user.getRoleType()));
} }
Cookie cookie = new Cookie("TOKEN", token); Cookie cookie = new Cookie("TOKEN", token);
cookie.setPath("/"); cookie.setPath("/");
cookie.setMaxAge(60 * 60 * 24 * 7); cookie.setMaxAge(60 * 60 * 24 * 7);
......
...@@ -78,6 +78,7 @@ public class UserController { ...@@ -78,6 +78,7 @@ public class UserController {
@RequestMapping(value = "/find/role", method = RequestMethod.GET) @RequestMapping(value = "/find/role", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResultModel findRole(@CurrentAccount User loginAccount) { public ResultModel findRole(@CurrentAccount User loginAccount) {
return ResultModel.OK(roleRepository.findAll()); return ResultModel.OK(roleRepository.findAll());
} }
......
...@@ -13,6 +13,8 @@ public class Auth { ...@@ -13,6 +13,8 @@ public class Auth {
private Long user; private Long user;
private String auth; private String auth;
private String authExtend;
private Long modifyAccount; private Long modifyAccount;
private Long createAccount; private Long createAccount;
private Date modifyTime; private Date modifyTime;
...@@ -45,6 +47,14 @@ public class Auth { ...@@ -45,6 +47,14 @@ public class Auth {
this.auth = auth; this.auth = auth;
} }
public String getAuthExtend() {
return authExtend;
}
public void setAuthExtend(String authExtend) {
this.authExtend = authExtend;
}
public Long getModifyAccount() { public Long getModifyAccount() {
return modifyAccount; return modifyAccount;
} }
......
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class AuthDic {
private Long id;
private String dicName;
private int index;
private int type;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDicName() {
return dicName;
}
public void setDicName(String dicName) {
this.dicName = dicName;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
...@@ -19,6 +19,7 @@ public class User { ...@@ -19,6 +19,7 @@ public class User {
private Long roleType; private Long roleType;
private String roleTypeName; private String roleTypeName;
private String auth; private String auth;
private String authExtend;
private Boolean status; private Boolean status;
private Long parent; private Long parent;
...@@ -128,6 +129,15 @@ public class User { ...@@ -128,6 +129,15 @@ public class User {
this.auth = auth; this.auth = auth;
} }
@Transient
public String getAuthExtend() {
return authExtend;
}
public void setAuthExtend(String authExtend) {
this.authExtend = authExtend;
}
public Boolean getStatus() { public Boolean getStatus() {
return status; return status;
} }
......
...@@ -13,4 +13,7 @@ public interface ContractBodyRepository extends JpaRepository<ContractBody, Long ...@@ -13,4 +13,7 @@ public interface ContractBodyRepository extends JpaRepository<ContractBody, Long
@Query(value = "select * from contract_body where platform = ?1 ",nativeQuery = true) @Query(value = "select * from contract_body where platform = ?1 ",nativeQuery = true)
List<ContractBody> findByPlatform(String platform); List<ContractBody> findByPlatform(String platform);
@Query(value = "select distinct * from contract_body",nativeQuery = true)
List<ContractBody> findAllDis();
} }
...@@ -82,4 +82,16 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -82,4 +82,16 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select * from contract where contract_code =?2 and platform = ?1 ",nativeQuery = true) @Query(value = "select * from contract where contract_code =?2 and platform = ?1 ",nativeQuery = true)
Contract findOneByCode(String platform, String contractId); Contract findOneByCode(String platform, String contractId);
@Query(value = "select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and customer_body in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery = true)
List<Contract> findByDsContractBody(String startDate, String endDate, List<String> platforms, List bodyids, List<String> ids);
@Query(value = "select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and customer_body in ?4 and status!='del' order by ds desc",nativeQuery = true)
List<Contract> findByDsContractBody(String startDate, String endDate, String platform, List bodyids);
@Query(value = "select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and sale in ?4 and status!='del' order by ds desc",nativeQuery = true)
List<Contract> findByDsContractSalse(String startDate, String endDate, String platform, List salseid);
@Query(value = "select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and sale in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery = true)
List<Contract> findByDsContractSalse(String startDate, String endDate, List<String> platforms, List salseid, List<String> ids);
} }
...@@ -189,10 +189,15 @@ public class ContractServiceImpl implements ContractService { ...@@ -189,10 +189,15 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public List<ContractBody> findBody(String platform) { public List<ContractBody> findBody(String platform) {
if("all".equals(platform)){
List<ContractBody> all = contractBodyRepository.findAllDis();
return all;
}else{
List<ContractBody> common = contractBodyRepository.findByPlatform("common"); List<ContractBody> common = contractBodyRepository.findByPlatform("common");
List<ContractBody> byPlatform = contractBodyRepository.findByPlatform(platform); List<ContractBody> byPlatform = contractBodyRepository.findByPlatform(platform);
common.addAll(byPlatform); common.addAll(byPlatform);
return common; return common;
}
} }
...@@ -1073,42 +1078,81 @@ public class ContractServiceImpl implements ContractService { ...@@ -1073,42 +1078,81 @@ public class ContractServiceImpl implements ContractService {
List<String> ids = new ArrayList<>(idsDic.keySet()); List<String> ids = new ArrayList<>(idsDic.keySet());
if (loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())) {
List<User> userList = userService.findAllSons(loginAccount.getId()); if(RoleEnum.FINANCE.getKey().equals(loginAccount.getRole())){
List<Long> idList = new ArrayList<>(); //财务 按签约主体查看
idList.add(loginAccount.getId()); List bodyids = Arrays.asList(loginAccount.getAuthExtend().split(","));
for (User u : userList) { if (!StringUtils.isEmpty(contractId)) {
idList.add(u.getId());
if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsContractBody(startDate, endDate, platforms,bodyids,ids);
}
} else {
contractList = contractRepository.findByDsContractBody(startDate, endDate, platform,bodyids);
} }
// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList); }else if(RoleEnum.SALSEMAN.getKey().equals(loginAccount.getRole())){
//销售 按签约合同人查看
List salseid = Arrays.asList(loginAccount.getAuthExtend().split(","));
if (!StringUtils.isEmpty(contractId)) { if (!StringUtils.isEmpty(contractId)) {
//查看关联合同
if (ids != null && ids.size() > 0) { if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platforms, idList, ids); contractList = contractRepository.findByDsContractSalse(startDate, endDate, platforms,salseid,ids);
} }
} else { } else {
contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList); contractList = contractRepository.findByDsContractSalse(startDate, endDate, platform,salseid);
} }
}else{
} else {
// contractList = contractRepository.findByDs(startDate, endDate, platform);
if (!StringUtils.isEmpty(contractId)) { if (!StringUtils.isEmpty(contractId)) {
if (ids != null && ids.size() > 0) { if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, ids); contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, ids);
} }
} else { } else {
contractList = contractRepository.findByDs(startDate, endDate, platform); contractList = contractRepository.findByDs(startDate, endDate, platform);
} }
} }
// if (loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())) {
//
// List<User> userList = userService.findAllSons(loginAccount.getId());
// List<Long> idList = new ArrayList<>();
// idList.add(loginAccount.getId());
// for (User u : userList) {
// idList.add(u.getId());
// }
//
//// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList);
//
//
// if (!StringUtils.isEmpty(contractId)) {
// //查看关联合同
// if (ids != null && ids.size() > 0) {
// contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platforms, idList, ids);
// }
//
// } else {
// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList);
// }
//
//
// } else {
//// contractList = contractRepository.findByDs(startDate, endDate, platform);
//
// if (!StringUtils.isEmpty(contractId)) {
// if (ids != null && ids.size() > 0) {
// contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, ids);
// }
// } else {
// contractList = contractRepository.findByDs(startDate, endDate, platform);
// }
//
// }
Map<String, String> saleMap = new HashMap(); Map<String, String> saleMap = new HashMap();
Map<String, PackageType> typeMap = new HashMap(); Map<String, PackageType> typeMap = new HashMap();
...@@ -1157,8 +1201,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -1157,8 +1201,8 @@ public class ContractServiceImpl implements ContractService {
c.setPriceLevelName(packageBaseMap.get(c.getPriceLevel()) == null ? "" : packageBaseMap.get(c.getPriceLevel()).getPackageName()); c.setPriceLevelName(packageBaseMap.get(c.getPriceLevel()) == null ? "" : packageBaseMap.get(c.getPriceLevel()).getPackageName());
} }
// c.setCreateName(saleMap.containsKey(c.getCreateAccount()) ? saleMap.get(c.getCreateAccount()) : "");
c.setCreateName(saleMap.containsKey(c.getCreateAccount()) ? saleMap.get(c.getCreateAccount()) : "");
result.add(c); result.add(c);
} }
} }
......
...@@ -65,15 +65,15 @@ public class UserServiceImpl implements UserService { ...@@ -65,15 +65,15 @@ public class UserServiceImpl implements UserService {
resource.setStatus(true); resource.setStatus(true);
User save = userRepository.save(resource); User save = userRepository.save(resource);
if(resource.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey())){ // if(resource.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey())){
bussinussManService.create(login.getEmail(), save.getEmail(), save.getName(),"华北"); // bussinussManService.create(login.getEmail(), save.getEmail(), save.getName(),"华北");
salesManService.create(login.getEmail(), save.getEmail(), save.getName()); // salesManService.create(login.getEmail(), save.getEmail(), save.getName());
ioSalesManService.create(login.getEmail(), save.getEmail(), save.getName()); // ioSalesManService.create(login.getEmail(), save.getEmail(), save.getName());
} else if(resource.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())){ // } else if(resource.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())){
bussinussManService.create(login.getEmail(), save.getEmail(), save.getName(),"华南"); // bussinussManService.create(login.getEmail(), save.getEmail(), save.getName(),"华南");
salesManService.create(login.getEmail(), save.getEmail(), save.getName()); // salesManService.create(login.getEmail(), save.getEmail(), save.getName());
ioSalesManService.create(login.getEmail(), save.getEmail(), save.getName()); // ioSalesManService.create(login.getEmail(), save.getEmail(), save.getName());
} // }
//auth //auth
...@@ -81,6 +81,7 @@ public class UserServiceImpl implements UserService { ...@@ -81,6 +81,7 @@ public class UserServiceImpl implements UserService {
auth.setCreateTime(new Date()); auth.setCreateTime(new Date());
auth.setCreateAccount(login.getId()); auth.setCreateAccount(login.getId());
auth.setAuth(resource.getAuth()); auth.setAuth(resource.getAuth());
auth.setAuthExtend(resource.getAuthExtend());
auth.setUser(save.getId()); auth.setUser(save.getId());
authRepository.save(auth); authRepository.save(auth);
return save; return save;
...@@ -107,46 +108,50 @@ public class UserServiceImpl implements UserService { ...@@ -107,46 +108,50 @@ public class UserServiceImpl implements UserService {
auth.setModifyTime(new Date()); auth.setModifyTime(new Date());
auth.setModifyAccount(login.getId()); auth.setModifyAccount(login.getId());
auth.setAuth(resource.getAuth()); auth.setAuth(resource.getAuth());
auth.setAuthExtend(resource.getAuthExtend());
auth.setUser(save.getId()); auth.setUser(save.getId());
Auth authSave = authRepository.save(auth); Auth authSave = authRepository.save(auth);
if(null != save.getRoleType() && save.getRoleType().equals(RoleTypeEnum.COMMON.getKey())){
JSONArray rootArr = JSONArray.fromObject(authSave.getAuth()); // if(null != save.getRoleType() && save.getRoleType().equals(RoleTypeEnum.COMMON.getKey())){
List<String> authList = new ArrayList<>(); // JSONArray rootArr = JSONArray.fromObject(authSave.getAuth());
if(ValidateUtil.isValid(rootArr)){ // List<String> authList = new ArrayList<>();
for (int i = 0; i < rootArr.size(); i++) { // if(ValidateUtil.isValid(rootArr)){
JSONObject obj = rootArr.getJSONObject(i); // for (int i = 0; i < rootArr.size(); i++) {
authList.add(obj.getString("id")); // JSONObject obj = rootArr.getJSONObject(i);
} // authList.add(obj.getString("id"));
} // }
List<User> userList = findSonsAlive(save.getId()); // }
if(ValidateUtil.isValid(userList)){ // List<User> userList = findSonsAlive(save.getId());
List<Long> ids = new ArrayList<>(); // if(ValidateUtil.isValid(userList)){
for(User u : userList){ // List<Long> ids = new ArrayList<>();
ids.add(u.getId()); // for(User u : userList){
} // ids.add(u.getId());
List<Auth> list = authRepository.findAllByUsers(ids); // }
if(ValidateUtil.isValid(list)){ // List<Auth> list = authRepository.findAllByUsers(ids);
List<Auth> authListSave = new ArrayList<>(); // if(ValidateUtil.isValid(list)){
for(Auth a : list){ // List<Auth> authListSave = new ArrayList<>();
String authStr = a.getAuth(); // for(Auth a : list){
JSONArray arrSave = new JSONArray(); // String authStr = a.getAuth();
JSONArray arr = JSONArray.fromObject(authStr); // JSONArray arrSave = new JSONArray();
if(ValidateUtil.isValid(arr)){ // JSONArray arr = JSONArray.fromObject(authStr);
for (int i = 0; i < arr.size(); i++) { // if(ValidateUtil.isValid(arr)){
JSONObject obj = arr.getJSONObject(i); // for (int i = 0; i < arr.size(); i++) {
if(authList.contains(obj.getString("id"))){ // JSONObject obj = arr.getJSONObject(i);
arrSave.add(obj); // if(authList.contains(obj.getString("id"))){
} // arrSave.add(obj);
} // }
} // }
a.setAuth(arrSave.toString()); // }
authListSave.add(a); // a.setAuth(arrSave.toString());
} // authListSave.add(a);
authRepository.save(authSave); // }
} //
} // // 这是什么操作?
} // authRepository.save(authSave);
// }
// }
// }
return save; return save;
} }
......
...@@ -6,9 +6,13 @@ package dic; ...@@ -6,9 +6,13 @@ package dic;
*/ */
public enum RoleEnum { public enum RoleEnum {
MANAGER(1L,"管理员"), MANAGER(1L, "管理员"),
NORTH_BUSSINUSS(2L,"北区商务"), NORTH_BUSSINUSS(2L, "北区商务"),
SOUTH_BUSSINUSS(3L,"南区商务"); SOUTH_BUSSINUSS(3L, "南区商务"),
SALSEMAN(3L, "销售"),
FINANCE(2L, "财务"),
PM(4L, "项目经理");
private Long key; private Long key;
......
...@@ -59,6 +59,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { ...@@ -59,6 +59,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|| requestURL.indexOf("update/pwd") != -1 || requestURL.indexOf("update/pwd") != -1
|| requestURL.indexOf("user/forget") != -1 || requestURL.indexOf("user/forget") != -1
|| requestURL.indexOf("user/code") != -1 || requestURL.indexOf("user/code") != -1
|| requestURL.indexOf("txt2db") != -1
|| requestURL.indexOf("contract/build") != -1 || requestURL.indexOf("contract/build") != -1
|| requestURL.indexOf("accountmng/findSaleInfo") != -1){ || requestURL.indexOf("accountmng/findSaleInfo") != -1){
return true; return true;
......
...@@ -22,6 +22,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -22,6 +22,7 @@ public class AccountServiceImpl implements AccountService {
@Autowired @Autowired
AccountRepository accountRepository; AccountRepository accountRepository;
@Override @Override
public Account update(Contract contract) { public Account update(Contract contract) {
......
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