拆分think模块包
This commit is contained in:
@@ -0,0 +1,318 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.FileRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.FileRecordService;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.entity.AppUrl;
|
||||
import com.gxwebsoft.oa.entity.AppUser;
|
||||
import com.gxwebsoft.oa.param.AppParam;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.oa.service.AppUrlService;
|
||||
import com.gxwebsoft.oa.service.AppUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.AppUserConstants.ADMINISTRATOR;
|
||||
|
||||
/**
|
||||
* 应用管理记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-26 22:06:23
|
||||
*/
|
||||
@Api(tags = "应用管理记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/app")
|
||||
public class AppController extends BaseController {
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
@Resource
|
||||
private AppUrlService appUrlService;
|
||||
@Resource
|
||||
private FileRecordService fileRecordService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<Map<String, Integer>> data() {
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
Integer totalNum = appService.count(
|
||||
new LambdaQueryWrapper<>()
|
||||
);
|
||||
Integer totalNum2 = appService.count(
|
||||
new LambdaQueryWrapper<App>()
|
||||
.eq(App::getAppStatus, "开发中")
|
||||
);
|
||||
Integer totalNum3 = appService.count(
|
||||
new LambdaQueryWrapper<App>()
|
||||
.eq(App::getAppStatus, "已上架")
|
||||
);
|
||||
Integer totalNum4 = appService.count(
|
||||
new LambdaQueryWrapper<App>()
|
||||
.eq(App::getAppStatus, "已上架")
|
||||
.eq(App::getShowExpiration,false)
|
||||
);
|
||||
Integer totalNum5 = appService.count(
|
||||
new LambdaQueryWrapper<App>()
|
||||
.eq(App::getAppStatus, "已下架")
|
||||
);
|
||||
Integer totalNum6 = appService.count(
|
||||
new LambdaQueryWrapper<App>()
|
||||
.eq(App::getShowCase,true)
|
||||
);
|
||||
Integer totalNum7 = appService.count(
|
||||
new LambdaQueryWrapper<App>()
|
||||
.eq(App::getShowIndex, true)
|
||||
);
|
||||
|
||||
data.put("totalNum", totalNum);
|
||||
data.put("totalNum2", totalNum2);
|
||||
data.put("totalNum3", totalNum3);
|
||||
data.put("totalNum4", totalNum4);
|
||||
data.put("totalNum5", totalNum5);
|
||||
data.put("totalNum6", totalNum6);
|
||||
data.put("totalNum7", totalNum7);
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询应用管理记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<App>> page(AppParam param, HttpServletRequest request) {
|
||||
final User loginUser = getLoginUser();
|
||||
// 未登录情况
|
||||
if(loginUser == null){
|
||||
String access_token = JwtUtil.getAccessToken(request);
|
||||
param.setToken(access_token);
|
||||
return success("案例列表",caseList(param));
|
||||
}
|
||||
final Integer userId = loginUser.getUserId();
|
||||
loginUser.getRoles().forEach(d -> {
|
||||
if(!StrUtil.equals(d.getRoleCode(),"superAdmin") && !StrUtil.equals(d.getRoleCode(),"admin")){
|
||||
// 非管理员按项目成员权限显示
|
||||
final List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId, userId));
|
||||
System.out.println("list = " + list);
|
||||
final Set<Integer> collect = list.stream().map(AppUser::getAppId).collect(Collectors.toSet());
|
||||
param.setAppIds(collect);
|
||||
}
|
||||
});
|
||||
// 过滤续费提醒参数
|
||||
if (param.getAppStatus() != null && param.getAppStatus().equals("续费中")) {
|
||||
param.setAppStatus(null);
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(appService.pageRel(param));
|
||||
}
|
||||
|
||||
// 读取案例列表
|
||||
private PageResult<App> caseList(AppParam param){
|
||||
param.setShowCase(true);
|
||||
final PageResult<App> appPageResult = appService.pageRel(param);
|
||||
appPageResult.getList().forEach(d -> {
|
||||
d.setContent(null);
|
||||
// 读取账号列表
|
||||
d.setAppUrlList(appUrlService.list(new LambdaQueryWrapper<AppUrl>().eq(AppUrl::getAppId,d.getAppId())));
|
||||
// 读取项目附件(链式构建GET请求)
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("appId", d.getAppId());
|
||||
final String build = UrlBuilder.of("https://server.gxwebsoft.com/api/file/page").setQuery(new UrlQuery(map)).build();
|
||||
String response = HttpRequest.get(build)
|
||||
.header("Authorization", param.getToken())
|
||||
.header("Tenantid", d.getTenantId().toString())
|
||||
.body(JSONObject.toJSONString(map))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
final ApiResult<PageResult<FileRecord>> userResult = JSONObject.parseObject(response, new TypeReference<ApiResult<PageResult<FileRecord>>>() {
|
||||
});
|
||||
d.setAppFiles(userResult.getData().getList());
|
||||
});
|
||||
return appPageResult;
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:app:list')")
|
||||
@ApiOperation("查询全部应用管理记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<App>> list(AppParam param) {
|
||||
// 使用关联查询
|
||||
return success(appService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询应用管理记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<App> get(@PathVariable("id") Integer id) {
|
||||
final User loginUser = getLoginUser();
|
||||
// 未登录情况
|
||||
if(loginUser == null){
|
||||
return success("案例详情",getDesensitizedApp(id));
|
||||
}
|
||||
if (!CommonUtil.hasRole(loginUser.getRoles(),"superAdmin") && !CommonUtil.hasRole(loginUser.getRoles(),"admin")) {
|
||||
// 查询权限
|
||||
if (appUserService.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId, getLoginUserId()).eq(AppUser::getAppId,id)) == 0) {
|
||||
return fail("无查看权限",null);
|
||||
}
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(appService.getByIdRel(id));
|
||||
}
|
||||
|
||||
private App getDesensitizedApp(Integer id) {
|
||||
final App app = appService.getByIdRel(id);
|
||||
app.setPhone(DesensitizedUtil.mobilePhone(app.getPhone()));
|
||||
app.setCompanyName(
|
||||
StrUtil.hide(app.getCompanyName(), 2, app.getCompanyName().length() - 2));
|
||||
app.setRequirement(DesensitizedUtil.chineseName(app.getCompanyName()));
|
||||
return app;
|
||||
}
|
||||
|
||||
@ApiOperation("添加应用管理记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody App app) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
AppUser appUser = new AppUser();
|
||||
if (loginUser != null) {
|
||||
app.setUserId(loginUser.getUserId());
|
||||
app.setTenantId(loginUser.getTenantId());
|
||||
}
|
||||
if (appService.count(new LambdaQueryWrapper<App>()
|
||||
.eq(App::getAppCode, app.getAppCode())) > 0) {
|
||||
return fail("应用标识已存在");
|
||||
}
|
||||
if (appService.save(app)) {
|
||||
// 添加应用管理员
|
||||
if (loginUser != null) {
|
||||
appUser.setUserId(loginUser.getUserId());
|
||||
appUser.setNickname(loginUser.getNickname());
|
||||
appUser.setAppId(app.getAppId());
|
||||
appUser.setRole(ADMINISTRATOR);
|
||||
appUserService.save(appUser);
|
||||
}
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改应用管理记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody App app) {
|
||||
if (appService.updateById(app)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除应用管理记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加应用管理记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<App> list) {
|
||||
if (appService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改应用管理记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<App> batchParam) {
|
||||
if (batchParam.update(appService, "app_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除应用管理记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("重置秘钥")
|
||||
@PostMapping("/updateAppSecret")
|
||||
public ApiResult<?> updateAppSecret(@RequestBody App app) {
|
||||
String key = "code:" + app.getPhone();
|
||||
final String code = redisUtil.get(key);
|
||||
if (app.getAppId() == null) {
|
||||
return fail("appId不合法");
|
||||
}
|
||||
if(app.getAppSecret() == null){
|
||||
return fail("appSecret不合法");
|
||||
}
|
||||
if(app.getAppCode() == null){
|
||||
return fail("短信验证码不正确");
|
||||
}
|
||||
// && !app.getAppCode().equals("170083")
|
||||
if(!app.getAppCode().equals(code)){
|
||||
return fail("短信验证码不正确");
|
||||
}
|
||||
appService.updateById(app);
|
||||
// 保存到redis
|
||||
redisUtil.set("AppSecret:" + app.getAppId(),app.getAppSecret());
|
||||
redisUtil.delete(key);
|
||||
return success("重置成功",app.getAppSecret());
|
||||
}
|
||||
|
||||
@ApiOperation("APP应用授权身份效验")
|
||||
@GetMapping("/authentication/{appid}")
|
||||
public ApiResult<?> authentication(@PathVariable("appid") String appid) {
|
||||
final App appInfo = appService.getById(appid);
|
||||
if(appInfo == null){
|
||||
return fail("应用不存在:".concat(appid));
|
||||
}
|
||||
return success("应用信息",appInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("查询我的项目信息")
|
||||
@GetMapping("/getMyApp")
|
||||
public ApiResult<App> getMyApp() {
|
||||
final User loginUser = getLoginUser();
|
||||
// 未登录情况
|
||||
if(loginUser == null){
|
||||
return fail("请先登录",null);
|
||||
}
|
||||
appService.list();
|
||||
|
||||
// 使用关联查询
|
||||
return success("查询成功",null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.AppField;
|
||||
import com.gxwebsoft.oa.param.AppFieldParam;
|
||||
import com.gxwebsoft.oa.service.AppFieldService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用参数控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-01-12 20:08:35
|
||||
*/
|
||||
@Api(tags = "应用参数管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/app-field")
|
||||
public class AppFieldController extends BaseController {
|
||||
@Resource
|
||||
private AppFieldService appFieldService;
|
||||
|
||||
@ApiOperation("分页查询应用参数")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppField>> page(AppFieldParam param) {
|
||||
PageParam<AppField, AppFieldParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number desc");
|
||||
page.setDefaultOrder("create_time asc");
|
||||
return success(appFieldService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(appFieldService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部应用参数")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppField>> list(AppFieldParam param) {
|
||||
PageParam<AppField, AppFieldParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(appFieldService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(appFieldService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询应用参数")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppField> get(@PathVariable("id") Integer id) {
|
||||
return success(appFieldService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(appFieldService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加应用参数")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppField appField) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
appField.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (appFieldService.save(appField)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改应用参数")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppField appField) {
|
||||
if (appFieldService.updateById(appField)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除应用参数")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appFieldService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加应用参数")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppField> list) {
|
||||
if (appFieldService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改应用参数")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AppField> batchParam) {
|
||||
if (batchParam.update(appFieldService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除应用参数")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appFieldService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.entity.AppRenew;
|
||||
import com.gxwebsoft.oa.param.AppRenewParam;
|
||||
import com.gxwebsoft.oa.service.AppRenewService;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 续费管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-11-14 14:27:57
|
||||
*/
|
||||
@Api(tags = "续费管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/app-renew")
|
||||
public class AppRenewController extends BaseController {
|
||||
@Resource
|
||||
private AppRenewService appRenewService;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@ApiOperation("分页查询续费管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppRenew>> page(AppRenewParam param) {
|
||||
// 使用关联查询
|
||||
return success(appRenewService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部续费管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppRenew>> list(AppRenewParam param) {
|
||||
// 使用关联查询
|
||||
return success(appRenewService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询续费管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppRenew> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(appRenewService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加续费管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppRenew appRenew) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
appRenew.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (appRenewService.save(appRenew)) {
|
||||
// 更新到期时间
|
||||
App app = appService.getById(appRenew.getAppId());
|
||||
app.setExpirationTime(appRenew.getEndTime());
|
||||
app.setRenewMoney(appRenew.getMoney());
|
||||
app.setShowExpiration(true);
|
||||
appService.updateById(app);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改续费管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppRenew appRenew) {
|
||||
if (appRenewService.updateById(appRenew)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除续费管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appRenewService.removeById(id)) {
|
||||
// 没有续费单则不显示在续费提醒列表
|
||||
AppRenew appRenew = appRenewService.getById(id);
|
||||
if (appRenewService.count(new LambdaQueryWrapper<AppRenew>().eq(AppRenew::getAppId,appRenew.getAppId())) == 0) {
|
||||
App app = new App();
|
||||
app.setAppId(appRenew.getAppId());
|
||||
app.setShowExpiration(false);
|
||||
appService.updateById(app);
|
||||
}
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加续费管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppRenew> list) {
|
||||
if (appRenewService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改续费管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AppRenew> batchParam) {
|
||||
if (batchParam.update(appRenewService, "app_renew_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除续费管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appRenewService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.oa.service.AppUrlService;
|
||||
import com.gxwebsoft.oa.entity.AppUrl;
|
||||
import com.gxwebsoft.oa.param.AppUrlParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目域名控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-15 13:01:34
|
||||
*/
|
||||
@Api(tags = "项目域名管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/app-url")
|
||||
public class AppUrlController extends BaseController {
|
||||
@Resource
|
||||
private AppUrlService appUrlService;
|
||||
|
||||
@ApiOperation("分页查询项目域名")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppUrl>> page(AppUrlParam param) {
|
||||
// 使用关联查询
|
||||
return success(appUrlService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部项目域名")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppUrl>> list(AppUrlParam param) {
|
||||
// 使用关联查询
|
||||
return success(appUrlService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询项目域名")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppUrl> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(appUrlService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加项目域名")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppUrl appUrl) {
|
||||
if (appUrlService.save(appUrl)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改项目域名")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppUrl appUrl) {
|
||||
if (appUrlService.updateById(appUrl)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除项目域名")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appUrlService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加项目域名")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppUrl> list) {
|
||||
if (appUrlService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改项目域名")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AppUrl> batchParam) {
|
||||
if (batchParam.update(appUrlService, "app_url_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除项目域名")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appUrlService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.oa.entity.AppUser;
|
||||
import com.gxwebsoft.oa.param.AppUserParam;
|
||||
import com.gxwebsoft.oa.service.AppUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用成员控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-26 22:06:23
|
||||
*/
|
||||
@Api(tags = "应用成员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/app-user")
|
||||
public class AppUserController extends BaseController {
|
||||
@Resource
|
||||
private AppUserService appUserService;
|
||||
|
||||
@ApiOperation("分页查询应用成员")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AppUser>> page(AppUserParam param, HttpServletRequest request) {
|
||||
// 使用关联查询
|
||||
param.setToken(JwtUtil.getAccessToken(request));
|
||||
param.setTenantId(getTenantId());
|
||||
return success(appUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部应用成员")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AppUser>> list(AppUserParam param) {
|
||||
// 使用关联查询
|
||||
if (param.getAppId() == null) {
|
||||
return fail("AppId不存在",null);
|
||||
}
|
||||
return success(appUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询应用成员")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AppUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(appUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加应用成员")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AppUser appUser) {
|
||||
if (appUserService.count(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getUserId, appUser.getUserId()).eq(AppUser::getAppId,appUser.getAppId())) > 0) {
|
||||
return fail("该成员已存在");
|
||||
}
|
||||
if (appUserService.save(appUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改应用成员")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AppUser appUser) {
|
||||
if (appUserService.updateById(appUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除应用成员")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (appUserService.removeById(id)) {
|
||||
return success("移除成功");
|
||||
}
|
||||
return fail("移除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加应用成员")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AppUser> list) {
|
||||
if (appUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改应用成员")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AppUser> batchParam) {
|
||||
if (batchParam.update(appUserService, "app_user_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除应用成员")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (appUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.utils.BtUtil;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Assets;
|
||||
import com.gxwebsoft.oa.entity.AssetsUser;
|
||||
import com.gxwebsoft.oa.param.AssetsParam;
|
||||
import com.gxwebsoft.oa.service.AssetsService;
|
||||
import com.gxwebsoft.oa.service.AssetsUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.AppUserConstants.ADMINISTRATOR;
|
||||
|
||||
/**
|
||||
* 服务器资产记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-26 21:08:27
|
||||
*/
|
||||
@Api(tags = "服务器资产记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/assets")
|
||||
public class AssetsController extends BaseController {
|
||||
@Resource
|
||||
private AssetsService assetsService;
|
||||
@Resource
|
||||
private AssetsUserService assetsUserService;
|
||||
@Resource
|
||||
private BtUtil btUtil;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<Map<String, Integer>> data() {
|
||||
final User loginUser = getLoginUser();
|
||||
final Integer userId = loginUser.getUserId();
|
||||
final List<String> collect1 = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toList());
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
if (collect1.contains("superAdmin") || collect1.contains("admin")) {
|
||||
Integer totalNum = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
);
|
||||
Integer totalNum1 = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
.gt(Assets::getEndTime, LocalDateTime.now())
|
||||
// .eq(Assets::getStatus, "运行中")
|
||||
);
|
||||
Integer totalNum2 = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
.lt(Assets::getEndTime, LocalDateTime.now())
|
||||
);
|
||||
Integer totalNum3 = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
.eq(Assets::getStatus, "已销毁")
|
||||
);
|
||||
data.put("totalNum", totalNum);
|
||||
data.put("totalNum1", totalNum1);
|
||||
data.put("totalNum2", totalNum2);
|
||||
data.put("totalNum3", totalNum3);
|
||||
|
||||
// 处理已过期主机
|
||||
String key = "Assets:update:".concat(loginUser.getTenantId().toString());
|
||||
if(redisUtil.get(key) == null){
|
||||
final List<Assets> list = assetsService.list(new LambdaQueryWrapper<Assets>().lt(Assets::getEndTime, LocalDateTime.now()));
|
||||
list.forEach(d -> {
|
||||
d.setStatus("已到期");
|
||||
});
|
||||
if (assetsService.updateBatchById(list)) {
|
||||
redisUtil.set(key,1,1L, TimeUnit.DAYS);
|
||||
}
|
||||
}
|
||||
return success(data);
|
||||
}
|
||||
// 非管理员
|
||||
final List<AssetsUser> list = assetsUserService.list(new LambdaQueryWrapper<AssetsUser>().eq(AssetsUser::getUserId, userId));
|
||||
final Set<Integer> collect = list.stream().map(AssetsUser::getAssetsId).collect(Collectors.toSet());
|
||||
Integer totalNum = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>().in(Assets::getAssetsId,collect)
|
||||
);
|
||||
Integer totalNum1 = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
.gt(Assets::getEndTime, LocalDateTime.now())
|
||||
.in(Assets::getAssetsId,collect)
|
||||
);
|
||||
Integer totalNum2 = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
.lt(Assets::getEndTime, LocalDateTime.now())
|
||||
.in(Assets::getAssetsId,collect)
|
||||
);
|
||||
Integer totalNum3 = assetsService.count(
|
||||
new LambdaQueryWrapper<Assets>()
|
||||
.eq(Assets::getStatus, "已销毁")
|
||||
.in(Assets::getAssetsId,collect)
|
||||
);
|
||||
|
||||
data.put("totalNum", totalNum);
|
||||
data.put("totalNum1", totalNum1);
|
||||
data.put("totalNum2", totalNum2);
|
||||
data.put("totalNum3", totalNum3);
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询服务器资产记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Assets>> page(AssetsParam param) {
|
||||
final User loginUser = getLoginUser();
|
||||
final Integer userId = loginUser.getUserId();
|
||||
final List<String> collect1 = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toList());
|
||||
if (collect1.contains("superAdmin") || collect1.contains("admin")) {
|
||||
// 返回查询结果
|
||||
return success(assetsService.pageRel(param));
|
||||
}
|
||||
|
||||
final List<AssetsUser> list = assetsUserService.list(new LambdaQueryWrapper<AssetsUser>().eq(AssetsUser::getUserId, userId));
|
||||
final Set<Integer> collect = list.stream().map(AssetsUser::getAssetsId).collect(Collectors.toSet());
|
||||
if(!CollectionUtils.isEmpty(collect)){
|
||||
param.setAssetsIds(collect);
|
||||
}
|
||||
return success(assetsService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部服务器资产记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Assets>> list(AssetsParam param) {
|
||||
// 使用关联查询
|
||||
return success(assetsService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询服务器资产记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Assets> get(@PathVariable("id") Integer id) {
|
||||
final Assets assets = assetsService.getByIdRel(id);
|
||||
// 查询宝塔接口
|
||||
if(StrUtil.isNotBlank(assets.getBtSign())){
|
||||
final BtUtil client = btUtil.client(id);
|
||||
final String systemTotal = client.getSystemTotal();
|
||||
final String diskInfo = client.getDiskInfo();
|
||||
assets.setSystemTotal(systemTotal);
|
||||
assets.setDiskInfo(diskInfo);
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(assets);
|
||||
}
|
||||
|
||||
@ApiOperation("添加服务器资产记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Assets assets) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
assets.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (assetsService.count(new LambdaQueryWrapper<Assets>().eq(Assets::getCode,assets.getCode())) > 0) {
|
||||
return fail("该IP地址已存在");
|
||||
}
|
||||
if (assetsService.save(assets)) {
|
||||
// 添加应用管理员
|
||||
if (loginUser != null) {
|
||||
final AssetsUser assetsUser = new AssetsUser();
|
||||
assetsUser.setUserId(loginUser.getUserId());
|
||||
assetsUser.setNickname(loginUser.getNickname());
|
||||
assetsUser.setAssetsId(assets.getAssetsId());
|
||||
assetsUser.setRole(ADMINISTRATOR);
|
||||
assetsUserService.save(assetsUser);
|
||||
}
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改服务器资产记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Assets assets) {
|
||||
if (assetsService.updateById(assets)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除服务器资产记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (assetsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加服务器资产记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Assets> list) {
|
||||
if (assetsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改服务器资产记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Assets> batchParam) {
|
||||
if (batchParam.update(assetsService, "assets_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除服务器资产记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (assetsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.oa.service.AssetsUserService;
|
||||
import com.gxwebsoft.oa.entity.AssetsUser;
|
||||
import com.gxwebsoft.oa.param.AssetsUserParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器成员管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-26 21:08:27
|
||||
*/
|
||||
@Api(tags = "服务器成员管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/assets-user")
|
||||
public class AssetsUserController extends BaseController {
|
||||
@Resource
|
||||
private AssetsUserService assetsUserService;
|
||||
|
||||
@ApiOperation("分页查询服务器成员管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AssetsUser>> page(AssetsUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(assetsUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部服务器成员管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AssetsUser>> list(AssetsUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(assetsUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询服务器成员管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AssetsUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(assetsUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加服务器成员管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AssetsUser assetsUser) {
|
||||
if (assetsUserService.count(new LambdaQueryWrapper<AssetsUser>()
|
||||
.eq(AssetsUser::getUserId, assetsUser.getUserId()).eq(AssetsUser::getAssetsId,assetsUser.getAssetsId())) > 0) {
|
||||
return fail("该成员已存在");
|
||||
}
|
||||
if (assetsUserService.save(assetsUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改服务器成员管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AssetsUser assetsUser) {
|
||||
if (assetsUserService.updateById(assetsUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除服务器成员管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (assetsUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加服务器成员管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AssetsUser> list) {
|
||||
if (assetsUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改服务器成员管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AssetsUser> batchParam) {
|
||||
if (batchParam.update(assetsUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除服务器成员管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (assetsUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Company;
|
||||
import com.gxwebsoft.oa.entity.CompanyUser;
|
||||
import com.gxwebsoft.oa.param.CompanyParam;
|
||||
import com.gxwebsoft.oa.service.CompanyService;
|
||||
import com.gxwebsoft.oa.service.CompanyUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.AppUserConstants.ADMINISTRATOR;
|
||||
|
||||
/**
|
||||
* 企业信息控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-23 19:18:58
|
||||
*/
|
||||
@Api(tags = "企业信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/company")
|
||||
public class CompanyController extends BaseController {
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
@Resource
|
||||
private CompanyUserService companyUserService;
|
||||
|
||||
@ApiOperation("分页查询企业信息")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Company>> page(CompanyParam param) {
|
||||
final User loginUser = getLoginUser();
|
||||
final Integer userId = loginUser.getUserId();
|
||||
loginUser.getRoles().forEach(d -> {
|
||||
if(!StrUtil.equals(d.getRoleCode(),"superAdmin") && !StrUtil.equals(d.getRoleCode(),"admin")){
|
||||
// 非管理员按项目成员权限显示
|
||||
final List<CompanyUser> list = companyUserService.list(new LambdaQueryWrapper<CompanyUser>().eq(CompanyUser::getUserId, userId));
|
||||
System.out.println("list = " + list);
|
||||
final Set<Integer> collect = list.stream().map(CompanyUser::getCompanyId).collect(Collectors.toSet());
|
||||
param.setCompanyIds(collect);
|
||||
}
|
||||
});
|
||||
// 使用关联查询
|
||||
return success(companyService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部企业信息")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Company>> list(CompanyParam param) {
|
||||
PageParam<Company, CompanyParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(companyService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(companyService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询企业信息")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Company> get(@PathVariable("id") Integer id) {
|
||||
return success(companyService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(companyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加企业信息")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Company company) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
CompanyUser companyUser = new CompanyUser();
|
||||
if (loginUser != null) {
|
||||
company.setUserId(loginUser.getUserId());
|
||||
company.setTenantId(loginUser.getTenantId());
|
||||
}
|
||||
if (companyService.save(company)) {
|
||||
// 添加客户所有者
|
||||
companyUser.setUserId(loginUser.getUserId());
|
||||
companyUser.setNickname(loginUser.getNickname());
|
||||
companyUser.setCompanyId(company.getCompanyId());
|
||||
companyUser.setRole(ADMINISTRATOR);
|
||||
companyUserService.save(companyUser);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改企业信息")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Company company) {
|
||||
if (companyService.updateById(company)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除企业信息")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (companyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加企业信息")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Company> list) {
|
||||
if (companyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改企业信息")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Company> batchParam) {
|
||||
if (batchParam.update(companyService, "company_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除企业信息")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (companyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.CompanyField;
|
||||
import com.gxwebsoft.oa.param.CompanyFieldParam;
|
||||
import com.gxwebsoft.oa.service.CompanyFieldService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业参数控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-02-04 14:44:42
|
||||
*/
|
||||
@Api(tags = "企业参数管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/company-field")
|
||||
public class CompanyFieldController extends BaseController {
|
||||
@Resource
|
||||
private CompanyFieldService companyFieldService;
|
||||
|
||||
@ApiOperation("分页查询企业参数")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<CompanyField>> page(CompanyFieldParam param) {
|
||||
PageParam<CompanyField, CompanyFieldParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number desc");
|
||||
page.setDefaultOrder("create_time asc");
|
||||
return success(companyFieldService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(companyFieldService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部企业参数")
|
||||
@GetMapping()
|
||||
public ApiResult<List<CompanyField>> list(CompanyFieldParam param) {
|
||||
PageParam<CompanyField, CompanyFieldParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(companyFieldService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(companyFieldService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询企业参数")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<CompanyField> get(@PathVariable("id") Integer id) {
|
||||
return success(companyFieldService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(companyFieldService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加企业参数")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody CompanyField companyField) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
companyField.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (companyFieldService.save(companyField)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改企业参数")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody CompanyField companyField) {
|
||||
if (companyFieldService.updateById(companyField)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除企业参数")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (companyFieldService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加企业参数")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<CompanyField> list) {
|
||||
if (companyFieldService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改企业参数")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<CompanyField> batchParam) {
|
||||
if (batchParam.update(companyFieldService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除企业参数")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (companyFieldService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.oa.entity.CompanyUser;
|
||||
import com.gxwebsoft.oa.param.CompanyUserParam;
|
||||
import com.gxwebsoft.oa.service.CompanyUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 成员管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-02-04 14:44:42
|
||||
*/
|
||||
@Api(tags = "成员管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/company-user")
|
||||
public class CompanyUserController extends BaseController {
|
||||
@Resource
|
||||
private CompanyUserService companyUserService;
|
||||
|
||||
@ApiOperation("分页查询成员管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<CompanyUser>> page(CompanyUserParam param, HttpServletRequest request) {
|
||||
// 使用关联查询
|
||||
param.setToken(JwtUtil.getAccessToken(request));
|
||||
param.setTenantId(getTenantId());
|
||||
return success(companyUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部成员管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<CompanyUser>> list(CompanyUserParam param) {
|
||||
// 使用关联查询
|
||||
if (param.getCompanyId() == null) {
|
||||
return fail("该企业不存在",null);
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(companyUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询成员管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<CompanyUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(companyUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加成员管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody CompanyUser companyUser) {
|
||||
if (companyUserService.count(new LambdaQueryWrapper<CompanyUser>()
|
||||
.eq(CompanyUser::getUserId, companyUser.getUserId()).eq(CompanyUser::getCompanyId,companyUser.getCompanyId())) > 0) {
|
||||
return fail("该成员已存在");
|
||||
}
|
||||
if (companyUserService.save(companyUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改成员管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody CompanyUser companyUser) {
|
||||
if (companyUserService.updateById(companyUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除成员管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (companyUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加成员管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<CompanyUser> list) {
|
||||
if (companyUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改成员管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<CompanyUser> batchParam) {
|
||||
if (batchParam.update(companyUserService, "company_user_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除成员管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (companyUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Link;
|
||||
import com.gxwebsoft.oa.param.LinkParam;
|
||||
import com.gxwebsoft.oa.service.LinkService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 常用链接控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-01-14 11:50:39
|
||||
*/
|
||||
@Api(tags = "常用链接管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/link")
|
||||
public class LinkController extends BaseController {
|
||||
@Resource
|
||||
private LinkService linkService;
|
||||
|
||||
@ApiOperation("分页查询常用链接")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Link>> page(LinkParam param) {
|
||||
// 使用关联查询
|
||||
return success(linkService.pageRel(param));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询全部常用链接")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Link>> list(LinkParam param) {
|
||||
// 使用关联查询
|
||||
return success(linkService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询常用链接")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Link> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(linkService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:link:save')")
|
||||
@ApiOperation("添加常用链接")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Link link) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
link.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (linkService.save(link)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:link:update')")
|
||||
@ApiOperation("修改常用链接")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Link link) {
|
||||
if (linkService.updateById(link)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:link:remove')")
|
||||
@ApiOperation("删除常用链接")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (linkService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:link:save')")
|
||||
@ApiOperation("批量添加常用链接")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Link> list) {
|
||||
if (linkService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:link:update')")
|
||||
@ApiOperation("批量修改常用链接")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Link> batchParam) {
|
||||
if (batchParam.update(linkService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:link:remove')")
|
||||
@ApiOperation("批量删除常用链接")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (linkService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Product;
|
||||
import com.gxwebsoft.oa.param.ProductParam;
|
||||
import com.gxwebsoft.oa.service.ProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-12-14 14:18:01
|
||||
*/
|
||||
@Api(tags = "产品记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/product")
|
||||
public class ProductController extends BaseController {
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@ApiOperation("分页查询产品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Product>> page(ProductParam param) {
|
||||
// 使用关联查询
|
||||
return success(productService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部产品记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Product>> list(ProductParam param) {
|
||||
// 使用关联查询
|
||||
return success(productService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询产品记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Product> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(productService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加产品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Product product) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
product.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (productService.save(product)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改产品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Product product) {
|
||||
if (productService.updateById(product)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除产品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (productService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加产品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Product> list) {
|
||||
if (productService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改产品记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Product> batchParam) {
|
||||
if (batchParam.update(productService, "product_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除产品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (productService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.ProductTabs;
|
||||
import com.gxwebsoft.oa.param.ProductTabsParam;
|
||||
import com.gxwebsoft.oa.service.ProductTabsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品标签记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-12-14 15:55:52
|
||||
*/
|
||||
@Api(tags = "产品标签记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/product-tabs")
|
||||
public class ProductTabsController extends BaseController {
|
||||
@Resource
|
||||
private ProductTabsService productTabsService;
|
||||
|
||||
@ApiOperation("分页查询产品标签记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ProductTabs>> page(ProductTabsParam param) {
|
||||
// 使用关联查询
|
||||
return success(productTabsService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部产品标签记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ProductTabs>> list(ProductTabsParam param) {
|
||||
// 使用关联查询
|
||||
return success(productTabsService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询产品标签记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ProductTabs> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(productTabsService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加产品标签记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ProductTabs productTabs) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
productTabs.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (productTabsService.save(productTabs)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改产品标签记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ProductTabs productTabs) {
|
||||
if (productTabsService.updateById(productTabs)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除产品标签记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (productTabsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加产品标签记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ProductTabs> list) {
|
||||
if (productTabsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改产品标签记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ProductTabs> batchParam) {
|
||||
if (batchParam.update(productTabsService, "tab_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除产品标签记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (productTabsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.MyQrCodeUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Task;
|
||||
import com.gxwebsoft.oa.entity.TaskCount;
|
||||
import com.gxwebsoft.oa.entity.TaskRecord;
|
||||
import com.gxwebsoft.oa.param.TaskParam;
|
||||
import com.gxwebsoft.oa.service.TaskCountService;
|
||||
import com.gxwebsoft.oa.service.TaskRecordService;
|
||||
import com.gxwebsoft.oa.service.TaskService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.TaskConstants.*;
|
||||
|
||||
/**
|
||||
* 任务记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-23 18:53:01
|
||||
*/
|
||||
@Api(tags = "任务记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/task")
|
||||
public class TaskController extends BaseController {
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private TaskRecordService taskRecordService;
|
||||
@Resource
|
||||
private TaskCountService taskCountService;
|
||||
|
||||
@ApiOperation("分页查询任务记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Task>> page(TaskParam param) {
|
||||
// 使用关联查询
|
||||
param.setLoginUserId(getLoginUserId());
|
||||
return success(taskService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部任务记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Task>> list(TaskParam param) {
|
||||
PageParam<Task, TaskParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(taskService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(taskService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询任务记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Task> get(@PathVariable("id") Integer id) {
|
||||
// 更新阅读状态
|
||||
Task task = taskService.getByIdRel(id);
|
||||
if(!task.getLastReadUser().equals(getLoginUserId())){
|
||||
task.setIsRead(1);
|
||||
taskService.updateById(task);
|
||||
}
|
||||
return success(task);
|
||||
}
|
||||
|
||||
@ApiOperation("添加任务记录表")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Task task) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
task.setUserId(loginUser.getUserId());
|
||||
Role role = loginUser.getRoles().get(0);
|
||||
task.setRoleId(role.getRoleId());
|
||||
task.setRoleCode(role.getRoleCode());
|
||||
task.setOrganizationId(loginUser.getOrganizationId());
|
||||
task.setAvatar(loginUser.getAvatar());
|
||||
task.setNickname(loginUser.getNickname());
|
||||
task.setLastAvatar(loginUser.getAvatar());
|
||||
task.setLastReadUser(loginUser.getUserId());
|
||||
task.setLastNickname(loginUser.getNickname());
|
||||
if(task.getName() == null){
|
||||
task.setName(task.getContent());
|
||||
}
|
||||
}
|
||||
if (taskService.saveByRel(task)) {
|
||||
return success("添加成功", task);
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改任务记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Task task) {
|
||||
if (taskService.updateById(task)) {
|
||||
// 更新统计表
|
||||
task.setLoginUserId(getLoginUserId());
|
||||
taskService.updateCount(task);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除任务记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (taskService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加任务记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Task> list) {
|
||||
if (taskService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改任务记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Task> batchParam) {
|
||||
if (batchParam.update(taskService, "task_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除任务记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (taskService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/count")
|
||||
public ApiResult<?> count(TaskParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
ArrayList<Object> countNum = taskService.getCountNum(loginUser, param);
|
||||
return success("操作成功", countNum);
|
||||
}
|
||||
|
||||
@ApiOperation("生成工单二维码")
|
||||
@GetMapping("/taskQRCode")
|
||||
public ApiResult<?> taskQRCode(TaskParam param, HttpServletRequest request) throws IOException {
|
||||
String url = "https://modules.gxwebsoft.com/oa/task/detail?id=".concat(param.getTaskId().toString());
|
||||
final String qrCode = MyQrCodeUtil.getTaskCode(param.getTaskId(),url);
|
||||
return success("操作成功", qrCode);
|
||||
}
|
||||
|
||||
@ApiOperation("生成邀请加入二维码")
|
||||
@GetMapping("/taskJoinQRCode")
|
||||
public ApiResult<?> taskJoinQRCode(TaskParam param, HttpServletRequest request) throws IOException {
|
||||
User loginUser = getLoginUser();
|
||||
String access_token = JwtUtil.getAccessToken(request);
|
||||
String url = "https://modules.gxwebsoft.com/passport/register?type=join&dealerId=".concat(loginUser.getUserId().toString())+"&token=".concat(access_token);
|
||||
final String qrCode = MyQrCodeUtil.getUserCode(loginUser.getUserId(),url);
|
||||
return success("操作成功", qrCode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每日清零
|
||||
*/
|
||||
@Scheduled(cron="0 0 0 * * ?")
|
||||
public void todayTask() {
|
||||
System.out.println("每日清零任务 = ");
|
||||
final boolean update = taskCountService.update(new LambdaUpdateWrapper<TaskCount>().set(TaskCount::getToday, 0));
|
||||
System.out.println("update = " + update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月清零
|
||||
*/
|
||||
@Scheduled(cron="0 0 1 * * ?")
|
||||
public void monthTask() {
|
||||
taskCountService.update(new LambdaUpdateWrapper<TaskCount>().set(TaskCount::getMonth, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 每年清零
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 1 * ?")
|
||||
public void yearTask(){
|
||||
taskCountService.update(new LambdaUpdateWrapper<TaskCount>().set(TaskCount::getYear, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时结算已解决待评价的工单的任务
|
||||
* 1个小时内没有用户再次提交新的回复则自动结算
|
||||
* 时间间隔2分钟执行一次
|
||||
*/
|
||||
@Scheduled(cron="*/30 * * * * *")
|
||||
public void updateProgressTask() {
|
||||
// System.out.println("定时任务开始:updateProgressTask = " + DateUtil.now());
|
||||
TaskParam taskParam = new TaskParam();
|
||||
taskParam.setProgress(TOBECONFIRMED);
|
||||
// taskParam.setTaskId(689);
|
||||
taskParam.setLimit(10L);
|
||||
final PageResult<Task> result = taskService.pageRelAll(taskParam);
|
||||
if(result.getCount() == 0){
|
||||
return;
|
||||
}
|
||||
final List<Task> list = result.getList();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(task -> {
|
||||
try {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date newDate = DateUtil.offset(task.getUpdateTime(), DateField.MINUTE, 60 * 24);
|
||||
Date date1 = df.parse(newDate.toString());
|
||||
Date date2 = df.parse(DateUtil.now());
|
||||
final boolean after = date2.after(date1);
|
||||
if(after){
|
||||
// 更新工单状态
|
||||
task.setProgress(COMPLETED);
|
||||
task.setStatus(TASK_STATUS_1);
|
||||
taskService.updateByIdAll(task);
|
||||
// 待评价的工单超过24小时没有评价则自动确认
|
||||
final TaskRecord taskRecord = new TaskRecord();
|
||||
taskRecord.setTaskId(task.getTaskId());
|
||||
taskRecord.setContent("超过24小时没有评价的工单系统已自动评价");
|
||||
taskRecord.setTenantId(task.getTenantId());
|
||||
final boolean save = taskRecordService.save(taskRecord);
|
||||
System.out.println("save = " + save);
|
||||
System.out.println("超过24小时没有评价的工单已自动确认 = " + task.getTaskId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Task;
|
||||
import com.gxwebsoft.oa.service.TaskCountService;
|
||||
import com.gxwebsoft.oa.entity.TaskCount;
|
||||
import com.gxwebsoft.oa.param.TaskCountParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.oa.service.TaskService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据统计控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-30 14:25:30
|
||||
*/
|
||||
@Api(tags = "数据统计管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/task-count")
|
||||
public class TaskCountController extends BaseController {
|
||||
@Resource
|
||||
private TaskCountService taskCountService;
|
||||
|
||||
@ApiOperation("分页查询数据统计")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TaskCount>> page(TaskCountParam param, HttpServletRequest request) {
|
||||
param.setToken(JwtUtil.getAccessToken(request));
|
||||
param.setTenantId(getTenantId());
|
||||
return success(taskCountService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部数据统计")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TaskCount>> list(TaskCountParam param) {
|
||||
PageParam<TaskCount, TaskCountParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(taskCountService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(taskCountService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询数据统计")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TaskCount> get(@PathVariable("id") Integer id) {
|
||||
return success(taskCountService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(taskCountService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加数据统计")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TaskCount taskCount) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
taskCount.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (taskCountService.save(taskCount)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改数据统计")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TaskCount taskCount) {
|
||||
if (taskCountService.updateById(taskCount)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除数据统计")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (taskCountService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加数据统计")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TaskCount> list) {
|
||||
if (taskCountService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改数据统计")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TaskCount> batchParam) {
|
||||
if (batchParam.update(taskCountService, "task_count_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除数据统计")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (taskCountService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.entity.Task;
|
||||
import com.gxwebsoft.oa.entity.TaskRecord;
|
||||
import com.gxwebsoft.oa.param.TaskRecordParam;
|
||||
import com.gxwebsoft.oa.service.TaskRecordService;
|
||||
import com.gxwebsoft.oa.service.TaskService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.TaskConstants.PENDING;
|
||||
import static com.gxwebsoft.common.core.constants.TaskConstants.PROCESSING;
|
||||
|
||||
/**
|
||||
* 工单回复记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-23 18:53:01
|
||||
*/
|
||||
@Api(tags = "工单回复记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/task-record")
|
||||
public class TaskRecordController extends BaseController {
|
||||
@Resource
|
||||
private TaskRecordService taskRecordService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
@ApiOperation("分页查询工单回复记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TaskRecord>> page(TaskRecordParam param, HttpServletRequest request) {
|
||||
param.setToken(JwtUtil.getAccessToken(request));
|
||||
param.setTenantId(getTenantId());
|
||||
return success(taskRecordService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部工单回复记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TaskRecord>> list(TaskRecordParam param) {
|
||||
PageParam<TaskRecord, TaskRecordParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(taskRecordService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(taskRecordService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询工单回复记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TaskRecord> get(@PathVariable("id") Integer id) {
|
||||
return success(taskRecordService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(taskRecordService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加工单回复记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TaskRecord taskRecord) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
taskRecord.setUserId(loginUser.getUserId());
|
||||
// 技术人员更新工单状态
|
||||
Task task = taskService.getById(taskRecord.getTaskId());
|
||||
if (CommonUtil.hasRole(loginUser.getRoles(),"commander") && task.getProgress().equals(PENDING)) {
|
||||
task.setProgress(PROCESSING);
|
||||
}
|
||||
task.setUpdateTime(new Date());
|
||||
task.setContent(taskRecord.getContent());
|
||||
task.setLastAvatar(loginUser.getAvatar());
|
||||
task.setLastReadUser(loginUser.getUserId());
|
||||
task.setLastNickname(loginUser.getNickname());
|
||||
taskService.updateById(task);
|
||||
}
|
||||
if (taskRecordService.save(taskRecord)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改工单回复记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TaskRecord taskRecord) {
|
||||
if (taskRecordService.updateById(taskRecord)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除工单回复记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (taskRecordService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加工单回复记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TaskRecord> list) {
|
||||
if (taskRecordService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改工单回复记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TaskRecord> batchParam) {
|
||||
if (batchParam.update(taskRecordService, "task_record_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除工单回复记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (taskRecordService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.service.TaskUserService;
|
||||
import com.gxwebsoft.oa.entity.TaskUser;
|
||||
import com.gxwebsoft.oa.param.TaskUserParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工单成员控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-23 18:53:01
|
||||
*/
|
||||
@Api(tags = "工单成员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/task-user")
|
||||
public class TaskUserController extends BaseController {
|
||||
@Resource
|
||||
private TaskUserService taskUserService;
|
||||
|
||||
@ApiOperation("分页查询工单成员")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TaskUser>> page(TaskUserParam param) {
|
||||
PageParam<TaskUser, TaskUserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(taskUserService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(taskUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部工单成员")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TaskUser>> list(TaskUserParam param) {
|
||||
PageParam<TaskUser, TaskUserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(taskUserService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(taskUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询工单成员")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TaskUser> get(@PathVariable("id") Integer id) {
|
||||
return success(taskUserService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(taskUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加工单成员")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TaskUser taskUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
taskUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (taskUserService.save(taskUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改工单成员")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TaskUser taskUser) {
|
||||
if (taskUserService.updateById(taskUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除工单成员")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (taskUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加工单成员")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TaskUser> list) {
|
||||
if (taskUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改工单成员")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TaskUser> batchParam) {
|
||||
if (batchParam.update(taskUserService, "task_user_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除工单成员")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (taskUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user