Commit 4028c3e3 by manxiaoqiang

app排序

parent 4b8bfbac
......@@ -11,6 +11,7 @@ import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
......@@ -27,6 +28,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
......@@ -51,28 +53,64 @@ public class ContractController {
return ResultModel.OK(service.findAll(startDate, endDate, platform));
}
@RequestMapping(value = "export", method = RequestMethod.GET)
@RequestMapping(value = "export", method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
public ResponseEntity<byte[]> export(@PathVariable String platform, @RequestParam String startDate
, @RequestParam String endDate, HttpServletRequest request, HttpServletResponse response) {
List<Contract> contractList = service.findAll(startDate, endDate, platform);
InputStream in = null;
byte[] content = new byte[0];
StringBuilder sb = new StringBuilder();
sb.append("时间,合同编号,客户账号,签约方,销售,开始日期,结束日期,套餐类型,合同金额,折扣,收款金额,合同状态\r\n");
if(ValidateUtil.isValid(contractList)){
for (Contract c : contractList){
sb.append(c.getDs()).append(c.getContractCode()).append(c.getEmail()).append(c.getCustomerBody()).append(c.getSaleName())
.append(c.getStartDate()).append(c.getEndDate()).append(c.getPriceLevelName()).append(c.getMoney()).append(c.getPayMoney())
.append(c.getStatus()).append("\r\n");
sb.append(c.getDs()).append(",").append(c.getContractCode()).append(",").append(c.getEmail()).append(",").append(c.getCustomerBody()).append(",").append(c.getSaleName()).append(",")
.append(c.getStartDate()).append(",").append(c.getEndDate()).append(",").append(c.getPriceLevelName()).append(",").append(c.getMoney()).append(",").append(c.getPayMoney()).append(",")
.append(c.getStatus()).append(",").append("\r\n");
}
}
InputStream in = new ByteArrayInputStream(sb.toString().getBytes());
try {
content = IOUtils.toByteArray(in);
} catch (IOException e) {
e.printStackTrace();
}
HttpHeaders headers = new HttpHeaders();
response.setHeader("filename", "contract.txt");
response.setHeader("content-disposition", "attachment; filename=contract.txt");
response.setHeader("Content-Type", "application/octet-stream;charset=UTF-8");
//返回文件字符串
return new ResponseEntity<byte[]>(content, headers, HttpStatus.CREATED);
}
@RequestMapping(value = "pay/export", method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
public ResponseEntity<byte[]> exportPay( @RequestParam String startDate, @RequestParam String endDate,
HttpServletRequest request, HttpServletResponse response) {
List<ContractMoney> moneyList = service.findPay(startDate, endDate);
byte[] content = new byte[0];
StringBuilder sb = new StringBuilder();
sb.append("合同编号 ,客户账号 ,签约方 ,事项 ,金额 ,日期 ,修改人 \r\n");
if(ValidateUtil.isValid(moneyList)){
for (ContractMoney c : moneyList){
sb.append(c.getContractCode()).append(",").append(c.getEmail()).append(",").append(c.getCompany()).append(",").append(c.getType()).append(",")
.append(c.getMoney()).append(",").append(c.getDs()).append(",").append(c.getCreateName()).append("\r\n");
}
}
content = sb.toString().getBytes();
InputStream in = new ByteArrayInputStream(sb.toString().getBytes());
try {
content = IOUtils.toByteArray(in);
} catch (IOException e) {
e.printStackTrace();
}
HttpHeaders headers = new HttpHeaders();
response.setHeader("filename", "contraact.xls");
response.setHeader("content-disposition", "attachment; filename=contraact.xls");
response.setHeader("Content-Type", "application/vnd.ms-excel");
response.setHeader("filename", "contract_pay.txt");
response.setHeader("content-disposition", "attachment; filename=contract_pay.txt");
response.setHeader("Content-Type", "application/octet-stream;charset=UTF-8");
//返回文件字符串
return new ResponseEntity<byte[]>(content, headers, HttpStatus.CREATED);
......
......@@ -53,7 +53,7 @@ public class UserController {
public ResultModel create(@CurrentAccount User loginAccount, @RequestBody User resource, HttpServletRequest request) {
if(userService.validEmail(resource.getEmail())){
userService.create(loginAccount, resource);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "创建系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "创建系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(true);
}else{
......@@ -64,7 +64,7 @@ public class UserController {
@RequestMapping(value = "/update", method = RequestMethod.PUT)
@ResponseBody
public ResultModel update(@CurrentAccount User loginAccount, @RequestBody User resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "修改系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), resource.getEmail(), "修改系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(userService.update(loginAccount, resource));
}
......@@ -97,7 +97,7 @@ public class UserController {
@ResponseBody
public ResultModel delete(@CurrentAccount User loginAccount, @PathVariable Long id, HttpServletRequest request) {
User user = userService.delete(loginAccount, id);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "删除系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "删除系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(user);
}
......@@ -106,7 +106,7 @@ public class UserController {
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @PathVariable Long id, HttpServletRequest request) {
User user = userService.enable(loginAccount, id);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "启用系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "启用系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(user);
}
......@@ -115,7 +115,7 @@ public class UserController {
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @PathVariable Long id, HttpServletRequest request) {
User user = userService.forbiden(loginAccount, id);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "停用系统账号", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "停用系统账号", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(user);
}
......@@ -126,7 +126,7 @@ public class UserController {
User login = userRepository.login(name);
if(null == login){
User user = userService.updateName(loginAccount, name);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号名字", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号名字", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(true);
}else{
......@@ -141,7 +141,7 @@ public class UserController {
User login = userRepository.login(loginAccount.getEmail(), CipherUtil.generatePassword(oldpwd));
if(null != login){
User user = userService.updatePwd(loginAccount, pwd);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号密码", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.INNERUSER.getKey(), user.getEmail(), "修改系统账号密码", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(true);
}else{
......@@ -153,7 +153,7 @@ public class UserController {
@RequestMapping(value = "/update/pwd", method = RequestMethod.PUT)
@ResponseBody
public ResultModel updatePwd(@RequestParam String email, @RequestParam String pwd, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(email, email, OperateObjectTypeEnum.INNERUSER.getKey(), email, "修改系统账号密码", request);
UserLogThread userlog = new UserLogThread(email, email, OperateObjectTypeEnum.INNERUSER.getKey(), email, "修改系统账号密码", request,null);
userlog.start();
return ResultModel.OK(userService.updatePwd(email, pwd));
}
......
......@@ -2,6 +2,7 @@ package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
......@@ -30,7 +31,7 @@ public class ContractChange {
private Date createTime;
@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
......
......@@ -23,6 +23,7 @@ public class UserLog
private String location;
private String OldObject;
private String newObject;
private Long role;
@Id
@GeneratedValue
......@@ -132,6 +133,14 @@ public class UserLog
this.newObject = newObject;
}
public Long getRole() {
return role;
}
public void setRole(Long role) {
this.role = role;
}
@Override
public String toString() {
return "UserLog{" +
......
......@@ -50,7 +50,7 @@ public class TkioAccountController {
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭异常状态跟进", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭异常状态跟进", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.forbiden(loginAccount, resource));
}
......@@ -59,7 +59,7 @@ public class TkioAccountController {
@RequestMapping(value = "/enable", method = RequestMethod.PUT)
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启异常状态跟进", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启异常状态跟进", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.enable(loginAccount, resource));
}
......@@ -68,7 +68,7 @@ public class TkioAccountController {
@RequestMapping(value = "/pay", method = RequestMethod.PUT)
@ResponseBody
public ResultModel pay(@CurrentAccount User loginAccount, @RequestBody Payment resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.pay(loginAccount, resource));
}
......@@ -77,7 +77,7 @@ public class TkioAccountController {
@RequestMapping(value = "/visit", method = RequestMethod.PUT)
@ResponseBody
public ResultModel visit(@CurrentAccount User loginAccount, @RequestBody BackVisit resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK( tkioAccountService.visit(loginAccount, resource));
}
......
......@@ -44,7 +44,7 @@ public class TrackAccountController {
@RequestMapping(value = "/forbiden", method = RequestMethod.PUT)
@ResponseBody
public ResultModel forbiden(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭到期提醒", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "关闭到期提醒", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.forbiden(loginAccount, resource));
}
......@@ -53,7 +53,7 @@ public class TrackAccountController {
@RequestMapping(value = "/enable", method = RequestMethod.PUT)
@ResponseBody
public ResultModel enable(@CurrentAccount User loginAccount, @RequestBody Reminder resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启到期提醒", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "开启到期提醒", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.enable(loginAccount, resource));
}
......@@ -62,7 +62,7 @@ public class TrackAccountController {
@RequestMapping(value = "/pay", method = RequestMethod.PUT)
@ResponseBody
public ResultModel pay(@CurrentAccount User loginAccount, @RequestBody Payment resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "缴费", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK(tkioAccountService.pay(loginAccount, resource));
}
......@@ -71,7 +71,7 @@ public class TrackAccountController {
@RequestMapping(value = "/visit", method = RequestMethod.PUT)
@ResponseBody
public ResultModel visit(@CurrentAccount User loginAccount, @RequestBody BackVisit resource, HttpServletRequest request) {
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request);
UserLogThread userlog = new UserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), resource.getEmail(), "回访", request,loginAccount.getRole());
userlog.start();
return ResultModel.OK( tkioAccountService.visit(loginAccount, resource));
}
......
......@@ -32,12 +32,14 @@ public class UserLogThread
//为了获取ip及解析地点
private HttpServletRequest request;
private Long role;
/**
* 传入内容为对象
* UserLogThread userlog = new UserLogThread("zxy@reyun.com", "zxy", OperateObjectTypeEnum.CUSTOMER.getKey(), "app", "查看app", request);
* userlog.start();
*/
public UserLogThread(String operaAccount, String accountName, String operateObjectType, String operateObject, String operateType, HttpServletRequest request)
public UserLogThread(String operaAccount, String accountName, String operateObjectType, String operateObject, String operateType, HttpServletRequest request, Long role)
{
this.operaAccount = operaAccount;
this.accountName = accountName;
......@@ -45,6 +47,7 @@ public class UserLogThread
this.operateObject = operateObject;
this.operateType = operateType;
this.request = request;
this.role = role;
}
......@@ -60,6 +63,7 @@ public class UserLogThread
audit.setOperateObject(this.operateObject);
audit.setOperateTime(DateUtil.format(new Date(), DateUtil.C_TIME_PATTON_DEFAULT));
audit.setOperateType(this.operateType);
audit.setRole(this.role);
if (this.request != null) {
String ipAddr = IPAddrUtil.getIpAddrNew(request);
......
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