Commit 144ed83a authored by xuxin's avatar xuxin

将专线回落的代码移动到 administratorController 下

parent e694e3cb
......@@ -6,7 +6,6 @@ import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.account.dto.SubUsersRequestDto;
import com.edgec.browserbackend.account.service.AccountService;
import com.edgec.browserbackend.browser.dto.ShopRequestDto;
import com.edgec.browserbackend.browser.service.TempService;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -23,8 +22,6 @@ public class AdminController {
@Autowired
AccountService accountService;
@Autowired
private TempService tempService;
@RequestMapping(path = "/subuser/addone", method = RequestMethod.POST)
public ResultDto createSubAccount(Principal principal, @Valid @RequestBody AccountDto user) {
......@@ -132,15 +129,4 @@ public class AdminController {
return resultDto;
}
/**
* 专线回落
*/
@PutMapping(value = "/updateip/{addr}/{flag}")
public ResultDto updateIp(@PathVariable String addr, @PathVariable String flag) {
tempService.saveIpResource(addr, flag);
ResultDto resultDto = new ResultDto();
resultDto.setStatus(0);
return resultDto;
}
}
package com.edgec.browserbackend.account.controller;
import com.edgec.browserbackend.account.domain.*;
import com.edgec.browserbackend.account.dto.BillQueryResultDto;
import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.account.dto.UserUsedDto;
import com.edgec.browserbackend.account.service.*;
import com.edgec.browserbackend.account.domain.*;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.browser.service.TempService;
import com.edgec.browserbackend.common.auth.Securitys;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -61,26 +61,29 @@ public class AdministratorController {
@Autowired
private AccountService accountService;
@Autowired
private TempService tempService;
//--------------------------------ROOT用户操作--------------------------------------//
//管理员注册tested
@PreAuthorize(Securitys.ROOT_EL)
@RequestMapping(path = "/0xadministrator",method = RequestMethod.POST)
public Administrator createNewAdministrator(@Valid @RequestBody Administrator administrator){
@RequestMapping(path = "/0xadministrator", method = RequestMethod.POST)
public Administrator createNewAdministrator(@Valid @RequestBody Administrator administrator) {
return administratorService.createAdministrator(administrator);
}
//删除管理员testing
@PreAuthorize(Securitys.ROOT_EL)
@RequestMapping(path = "/0xadministrator/{name}", method = RequestMethod.DELETE)
public void deleteAdmin( @PathVariable String name) {
public void deleteAdmin(@PathVariable String name) {
administratorService.deleteAdministrator(name);
}
// 查询所有的管理员
@PreAuthorize(Securitys.ROOT_EL)
@RequestMapping(path = "/0xadministrator",method = RequestMethod.GET)
public List<Administrator> getALLAdministrator(){
@RequestMapping(path = "/0xadministrator", method = RequestMethod.GET)
public List<Administrator> getALLAdministrator() {
return administratorService.getAllAdministrator();
}
......@@ -88,8 +91,8 @@ public class AdministratorController {
//修改管理员权限tested
@PreAuthorize(Securitys.ROOT_EL)
@RequestMapping(path = "/0xadministrator/{name}", method = RequestMethod.PUT)
public Administrator updateAgencyInfo(@PathVariable String name, @Valid @RequestBody String string){
return administratorService.updateAdministrator(name,string);
public Administrator updateAgencyInfo(@PathVariable String name, @Valid @RequestBody String string) {
return administratorService.updateAdministrator(name, string);
}
//用户通过银行转账,手动插入余额记录
......@@ -109,17 +112,15 @@ public class AdministratorController {
//--------------------------------用户--------------------------------------//
//根据用户的性名,或者电话,或者邮件,查询用户的信息tested
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchuser/{target}",method = RequestMethod.GET)
@RequestMapping(path = "/0xadministrator/searchuser/{target}", method = RequestMethod.GET)
public Account getAccountByTarget(@RequestParam("by") String by, @PathVariable String target) {
Account searchAccount = new Account();
if("name".equals(by)){
if ("name".equals(by)) {
searchAccount = administratorService.getAccountByName(target);
}
else if("phoneNumber".equals(by)){
} else if ("phoneNumber".equals(by)) {
searchAccount = administratorService.getAccountByPhoneNumber(target);
}
else if("email".equals(by)){
} else if ("email".equals(by)) {
searchAccount = administratorService.getAccountByEmail(target);
}
......@@ -129,26 +130,25 @@ public class AdministratorController {
//根据用户名查询用户账单tested
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchuserbill/{name}",method = RequestMethod.GET)
public BillQueryResultDto getUserBillByName(@PathVariable String name, @RequestParam("page") int page, @RequestParam("size") int size){
@RequestMapping(path = "/0xadministrator/searchuserbill/{name}", method = RequestMethod.GET)
public BillQueryResultDto getUserBillByName(@PathVariable String name, @RequestParam("page") int page, @RequestParam("size") int size) {
return administratorService.getUserBillingByName(name);
}
//给用户激活未激活或者被锁住的账户tested
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/unlockaccount/{name}",method = RequestMethod.PUT)
public Account unLockAccount(@PathVariable String name , @Valid @RequestBody Account account){
return administratorService.unLockLockedAccount(name,account);
@RequestMapping(path = "/0xadministrator/unlockaccount/{name}", method = RequestMethod.PUT)
public Account unLockAccount(@PathVariable String name, @Valid @RequestBody Account account) {
return administratorService.unLockLockedAccount(name, account);
}
//锁住异常用户tested
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/lockaccount/{name}",method = RequestMethod.PUT)
public Account lockAccount(@PathVariable String name , @Valid @RequestBody Account account){
return administratorService.lockAbnormalAccount(name,account);
@RequestMapping(path = "/0xadministrator/lockaccount/{name}", method = RequestMethod.PUT)
public Account lockAccount(@PathVariable String name, @Valid @RequestBody Account account) {
return administratorService.lockAbnormalAccount(name, account);
}
//查询用户余额
......@@ -190,32 +190,32 @@ public class AdministratorController {
//查看所有的用户<分页查询> tested
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchalluser",method = RequestMethod.GET)
public Page<Account> searchAllUser(@RequestParam(value="page")int page , @RequestParam(value="size")int size ){//(@PathVariable int page){
Pageable pageable = PageRequest.of(page,size);
@RequestMapping(path = "/0xadministrator/searchalluser", method = RequestMethod.GET)
public Page<Account> searchAllUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {//(@PathVariable int page){
Pageable pageable = PageRequest.of(page, size);
return administratorService.searchAllUserPage(pageable);
}
//查询某时段内增加的用户
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchperioduser",method = RequestMethod.GET)
public Page<Account> searchCreateAccount(@RequestParam(value="page") int page, @RequestParam(value="size") int size, @RequestParam(value="strDate1") String strDate1, @RequestParam(value="strDate2") String strDate2, @RequestParam(value = "isAuthorized", defaultValue = "5") int isAuthorized ){
@RequestMapping(path = "/0xadministrator/searchperioduser", method = RequestMethod.GET)
public Page<Account> searchCreateAccount(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "strDate1") String strDate1, @RequestParam(value = "strDate2") String strDate2, @RequestParam(value = "isAuthorized", defaultValue = "5") int isAuthorized) {
Pageable pageable = PageRequest.of(page, size);
return administratorService.searchCreateAccountBetween(pageable,strDate1,strDate2,isAuthorized);
return administratorService.searchCreateAccountBetween(pageable, strDate1, strDate2, isAuthorized);
}
// 查询所有用户消费
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/allused", method = RequestMethod.GET)
public Page<UserUsedDto> findAllused(@RequestParam(value="page")int page , @RequestParam(value="size")int size) {
public Page<UserUsedDto> findAllused(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
Pageable pageable = PageRequest.of(page, size);
return administratorService.getAllUserUsed(pageable);
}
//search company earnings detail by month tested
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/companyearning/{stringdate}",method = RequestMethod.GET)
public List<CompanyEarningsDto> getCompanyEarning(@PathVariable String stringdate ){
@RequestMapping(path = "/0xadministrator/companyearning/{stringdate}", method = RequestMethod.GET)
public List<CompanyEarningsDto> getCompanyEarning(@PathVariable String stringdate) {
return administratorService.getCompanyEarningDetail(stringdate);
}
......@@ -230,17 +230,18 @@ public class AdministratorController {
//查找某个用户或者代理有没有被锁住
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path = "/0xadministrator/lockstate/{name}",method = RequestMethod.GET)
public boolean getLockState(@PathVariable String name){
@RequestMapping(path = "/0xadministrator/lockstate/{name}", method = RequestMethod.GET)
public boolean getLockState(@PathVariable String name) {
return administratorService.getUserLockState(name);
}
//对欠费用户强制停机
/** 用户费率 */
/**
* 用户费率
*/
// 设置费率
@PreAuthorize(Securitys.ADMIN_EL)
......@@ -252,7 +253,7 @@ public class AdministratorController {
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/adduserrate", method = RequestMethod.POST)
public void insertUserRate(@RequestBody UserRate userRate){
public void insertUserRate(@RequestBody UserRate userRate) {
userRateService.addUserRate(userRate);
}
......@@ -290,10 +291,10 @@ public class AdministratorController {
//每月预付费统计分页展示
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/listReport", method = RequestMethod.GET)
public Page<CompanyMonthReport> listMonthReport(@RequestParam(value="page", defaultValue = "0") int page,
@RequestParam(value="size", defaultValue = "10") int size){
public Page<CompanyMonthReport> listMonthReport(@RequestParam(value = "page", defaultValue = "0") int page,
@RequestParam(value = "size", defaultValue = "10") int size) {
Pageable pageable = PageRequest.of(page,size);
Pageable pageable = PageRequest.of(page, size);
return monthReportService.listMonthReport(pageable);
}
......@@ -308,29 +309,29 @@ public class AdministratorController {
//获取用户企业认证的图片
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/authorize/files", method = RequestMethod.GET)
public ResultDto getAuthorizeFiles(Principal principal, @RequestParam("username")String username, HttpServletResponse response) {
public ResultDto getAuthorizeFiles(Principal principal, @RequestParam("username") String username, HttpServletResponse response) {
ResultDto resultDto = new ResultDto();
try {
File tempFile = accountService.getAuthorizeFiles(username);
try(OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(tempFile)){
try (OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(tempFile)) {
response.setHeader("content-type", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("Licenses.zip", "UTF-8"));
int len =0;
byte[] bt = new byte[5*1024];
while((len = fis.read(bt)) != -1) {
os.write(bt,0,len);
int len = 0;
byte[] bt = new byte[5 * 1024];
while ((len = fis.read(bt)) != -1) {
os.write(bt, 0, len);
}
}catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}finally {
} finally {
tempFile.delete();
}
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -348,7 +349,7 @@ public class AdministratorController {
try {
resultDto.setData(accountService.getAuthorizeDetails(username));
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -366,7 +367,7 @@ public class AdministratorController {
try {
resultDto.setData(accountService.setAuthorize(username, isAgree));
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -385,7 +386,7 @@ public class AdministratorController {
try {
administratorService.addPromotionCode(username, promotionCode);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -403,7 +404,7 @@ public class AdministratorController {
try {
administratorService.addWhiteList(website);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -421,7 +422,7 @@ public class AdministratorController {
try {
administratorService.addUserWhiteList(username, website);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -439,7 +440,7 @@ public class AdministratorController {
try {
resultDto.setData(administratorService.queyrIpCount(username));
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -452,15 +453,15 @@ public class AdministratorController {
//统计推广码下消费
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/promotioncode/query", method = RequestMethod.GET)
public ResultDto queryPromotion(Principal principal, @RequestParam(value="page") int page, @RequestParam(value="size") int size,
@RequestParam(value="strDate1") String strDate1, @RequestParam(value="strDate2") String strDate2,
public ResultDto queryPromotion(Principal principal, @RequestParam(value = "page") int page, @RequestParam(value = "size") int size,
@RequestParam(value = "strDate1") String strDate1, @RequestParam(value = "strDate2") String strDate2,
@RequestParam(value = "username", required = false) String username, @RequestParam(value = "promotionCode", required = false) String promotionCode) {
ResultDto resultDto = new ResultDto();
try {
Pageable pageable = PageRequest.of(page, size);
resultDto.setData(administratorService.queryPromotion(pageable, username, promotionCode, strDate1, strDate2));
resultDto.setStatus(0);
}catch (ClientRequestException e) {
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
......@@ -477,18 +478,18 @@ public class AdministratorController {
if (StringUtils.isNotBlank(key) && key.equals(mykey))
file = administratorService.getProxyConfig();
if (file != null) {
try(OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(file)){
try (OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(file)) {
response.setHeader("content-type", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("3proxy.cfg", "UTF-8"));
int len =0;
byte[] bt = new byte[50*1024];
while((len = fis.read(bt)) != -1) {
os.write(bt,0,len);
int len = 0;
byte[] bt = new byte[50 * 1024];
while ((len = fis.read(bt)) != -1) {
os.write(bt, 0, len);
}
}catch(Exception e) {
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
} finally {
......@@ -499,6 +500,24 @@ public class AdministratorController {
}
}
/**
* 专线回落
*/
@PutMapping(value = "/updateip/{addr}/{flag}")
public ResultDto updateIp(@PathVariable String addr, @PathVariable String flag) {
ResultDto resultDto = new ResultDto();
try {
tempService.saveIpResource(addr, flag);
resultDto.setStatus(0);
} catch (Exception e) {
resultDto.setStatus(-1);
resultDto.setData(e.getMessage());
}
return resultDto;
}
}
......
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