提交 72e0e579 authored 作者: liupengfei's avatar liupengfei

--no commit message

上级 ad5e1266
......@@ -20,4 +20,9 @@ public class URLConstant {
* 获取部门用户
*/
public static final String URL_USER_SIMPLELIST = "https://oapi.dingtalk.com/user/simplelist";
/**
* 获取管理员列表
*/
public static final String URL_ADMIN_LIST = "https://oapi.dingtalk.com/user/get_admin";
}
......@@ -2,6 +2,7 @@ package com.controller.customer;
import java.util.Date;
import com.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -31,11 +32,29 @@ public class CustomerController {
@ApiOperation(value = "保存客户信息", notes = "保存客户信息")
@PostMapping("/save")
public CallBack<?> save(Customer entity){
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
if (entity.getId() != null) {
Customer old = service.notNull(entity.getId());
entity.setCreater(old.getCreater());
entity.setCreateName(old.getCreateName());
// 修改指派时间标记,修改的用户和旧用户不一致的情况,则更新指派时间
boolean upFlag = StringUtils.isNotEmpty(entity.getUserId())
&& !entity.getUserId().equals(old.getUserId());
boolean upFlag1 = StringUtils.isNotEmpty(old.getUserId())
&& !old.getUserId().equals(entity.getUserId());
if (upFlag || upFlag1) {
entity.setAllotTime(new Date());
} else {
entity.setAllotTime(old.getAllotTime());
}
service.updateByPrimaryKey(entity);
return CallBack.success();
}
}
if (StringUtils.isNotEmpty(entity.getUserId())) {
// 添加客户时,指派了负责人,填充指派时间
entity.setAllotTime(new Date());
}
entity.setCreateTime(new Date());
service.insert(entity);
return CallBack.success(entity.getId());
}
......@@ -46,6 +65,7 @@ public class CustomerController {
return CallBack.success(service.page(pageParam, form));
}
@ApiOperation(value = "根据客户id查询客户信息")
@GetMapping("/get")
public CallBack<Customer> get(Integer id) {
......
......@@ -2,6 +2,10 @@ package com.controller.dingding;
import java.util.List;
import com.dingtalk.api.request.OapiUserGetAdminRequest;
import com.dingtalk.api.response.OapiUserGetAdminResponse;
import com.vo.dingding.AdminUserListVo;
import com.vo.dingding.AdminUserVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -71,4 +75,36 @@ public class UserController {
}
return ServiceResult.failure("-3", response.getBody());
}
/**
* Description: 获取管理员列表
* @param
* @return com.util.ServiceResult<java.util.List<?>>
* @author lpf
* @date 2020-04-02 15:50
*/
@GetMapping("/admin-list")
public ServiceResult<List<AdminUserVo>> adminList(){
// 获取调用接口凭证
String accessToken = AccessTokenUtil.getToken();
DingTalkClient client = new DefaultDingTalkClient(URLConstant.URL_ADMIN_LIST);
OapiUserGetAdminRequest request = new OapiUserGetAdminRequest();
request.setHttpMethod("GET");
OapiUserGetAdminResponse response;
try {
response = client.execute(request, accessToken);
} catch (ApiException e) {
e.printStackTrace();
log.error("获取管理员列表调用接口失败:" + e.toString());
return ServiceResult.failure("-2", "获取管理员列表调用接口失败:" + e.toString());
}
if (response.isSuccess()) {
AdminUserListVo vo = JSON.parseObject(response.getBody(), AdminUserListVo.class);
/*AdminUserVo lpf = new AdminUserVo();
lpf.setUserid("526150051021491847");
vo.getAdmin_list().add(lpf);*/
return ServiceResult.success(vo.getAdmin_list());
}
return ServiceResult.failure("-3", response.getBody());
}
}
......@@ -5,12 +5,13 @@ import java.util.Map;
import java.util.stream.Stream;
public enum CustomerHasBusinessEnum {
/** 未知 */
NONE("-1","未知"),
/** 是 */
YES("1","有"),
/** 否 */
NO("0","无");
NO("0","无"),
RELATION("1","关注,建立关系"),
FIND("2", "发现,发现商机线索"),
NEED("3", "和客户共同确定需求"),
DOC("4", "和客户共同确定方案"),
YES("5","赢得商机"),
PUT("6","实施");
private final String code;
private final String name;
......@@ -41,7 +42,7 @@ public enum CustomerHasBusinessEnum {
}
/**
* 判断名称是否有效
* @param name
* @param code
* @return
* @author lpf
* @date: 2018年6月11日 下午6:30:16
......@@ -59,7 +60,7 @@ public enum CustomerHasBusinessEnum {
* @date 2019年3月18日17:14:18
*/
public static String getName(String code) {
return stream().filter(e -> e.code.equals(code)).findFirst().map(e -> e.name).orElse(NONE.name);
return stream().filter(e -> e.code.equals(code)).findFirst().map(e -> e.name).orElse(NO.name);
}
/**
......@@ -71,7 +72,7 @@ public enum CustomerHasBusinessEnum {
* @date 2019年3月18日17:14:18
*/
public static String getCode(String name) {
return stream().filter(e -> e.name.equals(name)).findFirst().map(e -> e.code).orElse(NONE.code);
return stream().filter(e -> e.name.equals(name)).findFirst().map(e -> e.code).orElse(NO.code);
}
public String getCode() {
......
......@@ -31,7 +31,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<Customer, Integer> impl
@Override
public PageInfo<CustomerVo> page(PageParam pageParam, QueryCustomerForm form) {
if (StringUtils.isBlank(pageParam.getOrderBy())) {
pageParam.setOrderBy(" createTime desc ");
pageParam.setOrderBy(" updateTime desc ");
}
startPage(pageParam);
List<Customer> list = mapper.list(form);
......
package com.vo.dingding;
import com.util.DingTalkResult;
import lombok.Data;
import java.util.List;
/**
* Title: AdminUserListVo
* Description: 管理员集合
*
* @author lpf
* @version V1.0
* @date 2020-04-02
*/
@Data
public class AdminUserListVo extends DingTalkResult {
private List<AdminUserVo> admin_list;
}
package com.vo.dingding;
import lombok.Data;
/**
* Title: AdminUserVVo
* Description: 管理员用户vo
*
* @author lpf
* @version V1.0
* @date 2020-04-02
*/
@Data
public class AdminUserVo {
// 管理员角色 1:主管理员,2:子管理员
private String sys_level;
// 员工id
private String userid;
}
......@@ -43,6 +43,8 @@ spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: 'jdbc:mysql://192.168.2.220:3306/crm?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull'
# url: 'jdbc:mysql://localhost:3306/crm?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull'
username: root
password: "'>Nw0zPFwzv0'"
# password: root
initialize: true
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论