241019更新
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.gxwebsoft.cms.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.cms.service.DesignCategoryService;
|
||||
import com.gxwebsoft.cms.entity.DesignCategory;
|
||||
import com.gxwebsoft.cms.param.DesignCategoryParam;
|
||||
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.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
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-10-10 09:23:25
|
||||
*/
|
||||
@Api(tags = "设计征集报名分类管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/cms/design-category")
|
||||
public class DesignCategoryController extends BaseController {
|
||||
@Resource
|
||||
private DesignCategoryService designCategoryService;
|
||||
|
||||
@ApiOperation("分页查询设计征集报名分类")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DesignCategory>> page(DesignCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(designCategoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部设计征集报名分类")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DesignCategory>> list(DesignCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(designCategoryService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:designCategory:list')")
|
||||
@ApiOperation("根据id查询设计征集报名分类")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DesignCategory> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(designCategoryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加设计征集报名分类")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DesignCategory designCategory) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
designCategory.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (designCategoryService.save(designCategory)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改设计征集报名分类")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DesignCategory designCategory) {
|
||||
if (designCategoryService.updateById(designCategory)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除设计征集报名分类")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (designCategoryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加设计征集报名分类")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DesignCategory> list) {
|
||||
if (designCategoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改设计征集报名分类")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DesignCategory> batchParam) {
|
||||
if (batchParam.update(designCategoryService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除设计征集报名分类")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (designCategoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,17 +82,17 @@ public class WebsiteController extends BaseController {
|
||||
@ApiOperation("根据id查询网站信息记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Website> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
final Website website = websiteService.getByIdRel(id);
|
||||
// 附加状态说明
|
||||
website.setStatusName(WEBSITE_STATUS_NAME[website.getStatus()]);
|
||||
website.setStatusIcon(WEBSITE_STATUS_ICON[website.getStatus()]);
|
||||
website.setStatusUrl(WEBSITE_STATUS_URL[website.getStatus()]);
|
||||
website.setStatusBtnText(WEBSITE_STATUS_BTN_TEXT[website.getStatus()]);
|
||||
if (!website.getStatus().equals(2)) {
|
||||
website.setStatusText(WEBSITE_STATUS_TEXT[website.getStatus()]);
|
||||
}
|
||||
return success(website);
|
||||
// 使用关联查询
|
||||
final Website website = websiteService.getByIdRel(id);
|
||||
// 附加状态说明
|
||||
website.setStatusName(WEBSITE_STATUS_NAME[website.getStatus()]);
|
||||
website.setStatusIcon(WEBSITE_STATUS_ICON[website.getStatus()]);
|
||||
website.setStatusUrl(WEBSITE_STATUS_URL[website.getStatus()]);
|
||||
website.setStatusBtnText(WEBSITE_STATUS_BTN_TEXT[website.getStatus()]);
|
||||
if (!website.getStatus().equals(2)) {
|
||||
website.setStatusText(WEBSITE_STATUS_TEXT[website.getStatus()]);
|
||||
}
|
||||
return success(website);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:website:save')")
|
||||
@@ -102,7 +102,7 @@ public class WebsiteController extends BaseController {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
website.setUserId(loginUser.getUserId());
|
||||
website.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (websiteService.save(website)) {
|
||||
// 绑定免费二级域名
|
||||
@@ -166,143 +166,145 @@ public class WebsiteController extends BaseController {
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("检查域名是否存在")
|
||||
@GetMapping("/existence")
|
||||
public ApiResult<?> existence(ExistenceParam<Website> param) {
|
||||
if (param.isExistence(websiteService, Website::getWebsiteCode)) {
|
||||
return success(param.getValue() + "已存在");
|
||||
}
|
||||
return fail(param.getValue() + "不存在");
|
||||
}
|
||||
|
||||
@ApiOperation("网站基本信息")
|
||||
@GetMapping("/getSiteInfo")
|
||||
public ApiResult<Website> getSiteInfo(HttpServletRequest request) {
|
||||
String key = "SiteInfo:".concat(getTenantId().toString());
|
||||
final String siteInfo = redisUtil.get(key);
|
||||
String access_token = JwtUtil.getAccessToken(request);
|
||||
// 从缓存读取信息
|
||||
if(StrUtil.isNotBlank(siteInfo)){
|
||||
return success(JSONObject.parseObject(siteInfo,Website.class));
|
||||
@ApiOperation("检查域名是否存在")
|
||||
@GetMapping("/existence")
|
||||
public ApiResult<?> existence(ExistenceParam<Website> param) {
|
||||
if (param.isExistence(websiteService, Website::getWebsiteCode)) {
|
||||
return success(param.getValue() + "已存在");
|
||||
}
|
||||
return fail(param.getValue() + "不存在");
|
||||
}
|
||||
|
||||
// 判断是否存在
|
||||
if (websiteService.count() == 0) {
|
||||
return fail("站点不存在",null);
|
||||
@ApiOperation("网站基本信息")
|
||||
@GetMapping("/getSiteInfo")
|
||||
public ApiResult<Website> getSiteInfo(HttpServletRequest request) {
|
||||
String key = "SiteInfo:".concat(getTenantId().toString());
|
||||
final String siteInfo = redisUtil.get(key);
|
||||
String access_token = JwtUtil.getAccessToken(request);
|
||||
// 从缓存读取信息
|
||||
if (StrUtil.isNotBlank(siteInfo)) {
|
||||
return success(JSONObject.parseObject(siteInfo, Website.class));
|
||||
}
|
||||
|
||||
// 判断是否存在
|
||||
if (websiteService.count() == 0) {
|
||||
return fail("站点不存在", null);
|
||||
}
|
||||
|
||||
// 获取站点信息
|
||||
final Website website = websiteService.getOne(new LambdaQueryWrapper<Website>().eq(Website::getDeleted, 0).last("limit 1"));
|
||||
System.out.println("website = " + website);
|
||||
|
||||
// 站点配置参数
|
||||
HashMap<String, Object> config = new HashMap<>();
|
||||
final List<WebsiteField> fields = websiteFieldService.list();
|
||||
fields.forEach(d -> {
|
||||
config.put(d.getName(), d.getValue());
|
||||
});
|
||||
config.put("Domain", website.getDomain());
|
||||
config.put("SubDomain", website.getWebsiteCode().concat(".wsdns.cn"));
|
||||
website.setConfig(config);
|
||||
|
||||
// 网站导航
|
||||
final NavigationParam navigationParam = new NavigationParam();
|
||||
// 所有导航
|
||||
website.setNavigations(navigationService.listRel(navigationParam));
|
||||
navigationParam.setHide(0);
|
||||
navigationParam.setTop(0);
|
||||
navigationParam.setBottom(null);
|
||||
final List<Navigation> topNavs = navigationService.listRel(navigationParam);
|
||||
// 顶部菜单
|
||||
website.setTopNavs(CommonUtil.toTreeData(topNavs, 0, Navigation::getParentId, Navigation::getNavigationId, Navigation::setChildren));
|
||||
navigationParam.setTop(null);
|
||||
navigationParam.setBottom(0);
|
||||
final List<Navigation> bottomNavs = navigationService.listRel(navigationParam);
|
||||
// 底部菜单
|
||||
website.setBottomNavs(CommonUtil.toTreeData(bottomNavs, 0, Navigation::getParentId, Navigation::getNavigationId, Navigation::setChildren));
|
||||
|
||||
// 当前登录用户
|
||||
if (access_token != null) {
|
||||
final User loginUser = getLoginUser();
|
||||
website.setLoginUser(loginUser);
|
||||
}
|
||||
|
||||
// 服务器时间
|
||||
HashMap<String, Object> serverTime = new HashMap<>();
|
||||
// 今天日期
|
||||
DateTime date = DateUtil.date();
|
||||
String today = DateUtil.today();
|
||||
// 明天日期
|
||||
final DateTime dateTime = DateUtil.tomorrow();
|
||||
String tomorrow = DateUtil.format(dateTime, "yyyy-MM-dd");
|
||||
// 后天日期
|
||||
final DateTime dateTime2 = DateUtil.offsetDay(date, 2);
|
||||
final String afterDay = DateUtil.format(dateTime2, "yyyy-MM-dd");
|
||||
// 今天星期几
|
||||
final int week = DateUtil.thisDayOfWeek();
|
||||
final DateTime nextWeek = DateUtil.nextWeek();
|
||||
serverTime.put("now", DateUtil.now());
|
||||
serverTime.put("today", today);
|
||||
serverTime.put("tomorrow", tomorrow);
|
||||
serverTime.put("afterDay", afterDay);
|
||||
serverTime.put("week", week);
|
||||
serverTime.put("nextWeek", nextWeek);
|
||||
website.setServerTime(serverTime);
|
||||
redisUtil.set(key, website, 1L, TimeUnit.DAYS);
|
||||
|
||||
return success(website);
|
||||
}
|
||||
|
||||
// 获取站点信息
|
||||
final Website website = websiteService.getOne(new LambdaQueryWrapper<Website>().eq(Website::getDeleted, 0).last("limit 1"));
|
||||
System.out.println("website = " + website);
|
||||
private void createWebsite(String access_token) {
|
||||
final Integer tenantId = getTenantId();
|
||||
// 请求主服务器获取租户信息
|
||||
String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/tenant")
|
||||
.header("Authorization", access_token)
|
||||
.header("Tenantid", tenantId.toString())
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
// 站点配置参数
|
||||
HashMap<String, Object> config = new HashMap<>();
|
||||
final List<WebsiteField> fields = websiteFieldService.list();
|
||||
fields.forEach(d -> {
|
||||
config.put(d.getName(), d.getValue());
|
||||
});
|
||||
config.put("Domain", website.getDomain());
|
||||
config.put("SubDomain", website.getWebsiteCode().concat(".wsdns.cn"));
|
||||
website.setConfig(config);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
final String data = jsonObject.getString("data");
|
||||
final Company company = JSONObject.parseObject(data, Company.class);
|
||||
if (company == null) {
|
||||
throw new BusinessException("站点不存在");
|
||||
}
|
||||
// 创建网站记录
|
||||
final Website website = new Website();
|
||||
website.setTenantId(company.getTenantId());
|
||||
website.setWebsiteName(company.getShortName());
|
||||
website.setWebsiteLogo(company.getCompanyLogo());
|
||||
website.setWebsiteIcon("/favicon.ico");
|
||||
website.setWebsiteType("企业官网");
|
||||
website.setDomain(company.getDomain());
|
||||
website.setExpirationTime(company.getExpirationTime());
|
||||
website.setIndustryParent(company.getIndustryParent());
|
||||
website.setIndustryChild(company.getIndustryChild());
|
||||
website.setCompanyId(company.getCompanyId());
|
||||
website.setAddress(company.getAddress());
|
||||
website.setComments(company.getComments());
|
||||
website.setKeywords(company.getCompanyName());
|
||||
website.setUserId(company.getUserId());
|
||||
websiteService.save(website);
|
||||
|
||||
// 网站导航
|
||||
final NavigationParam navigationParam = new NavigationParam();
|
||||
navigationParam.setHide(0);
|
||||
navigationParam.setTop(0);
|
||||
navigationParam.setBottom(null);
|
||||
final List<Navigation> topNavs = navigationService.listRel(navigationParam);
|
||||
// 顶部菜单
|
||||
website.setTopNavs(CommonUtil.toTreeData(topNavs, 0, Navigation::getParentId, Navigation::getNavigationId, Navigation::setChildren));
|
||||
navigationParam.setTop(null);
|
||||
navigationParam.setBottom(0);
|
||||
final List<Navigation> bottomNavs = navigationService.listRel(navigationParam);
|
||||
// 底部菜单
|
||||
website.setBottomNavs(CommonUtil.toTreeData(bottomNavs, 0, Navigation::getParentId, Navigation::getNavigationId, Navigation::setChildren));
|
||||
|
||||
// 当前登录用户
|
||||
if(access_token != null){
|
||||
final User loginUser = getLoginUser();
|
||||
website.setLoginUser(loginUser);
|
||||
}
|
||||
|
||||
// 服务器时间
|
||||
HashMap<String, Object> serverTime = new HashMap<>();
|
||||
// 今天日期
|
||||
DateTime date = DateUtil.date();
|
||||
String today= DateUtil.today();
|
||||
// 明天日期
|
||||
final DateTime dateTime = DateUtil.tomorrow();
|
||||
String tomorrow = DateUtil.format(dateTime, "yyyy-MM-dd");
|
||||
// 后天日期
|
||||
final DateTime dateTime2 = DateUtil.offsetDay(date, 2);
|
||||
final String afterDay = DateUtil.format(dateTime2, "yyyy-MM-dd");
|
||||
// 今天星期几
|
||||
final int week = DateUtil.thisDayOfWeek();
|
||||
final DateTime nextWeek = DateUtil.nextWeek();
|
||||
serverTime.put("now",DateUtil.now());
|
||||
serverTime.put("today",today);
|
||||
serverTime.put("tomorrow",tomorrow);
|
||||
serverTime.put("afterDay",afterDay);
|
||||
serverTime.put("week",week);
|
||||
serverTime.put("nextWeek",nextWeek);
|
||||
website.setServerTime(serverTime);
|
||||
redisUtil.set(key,website,1L, TimeUnit.DAYS);
|
||||
|
||||
return success(website);
|
||||
}
|
||||
|
||||
private void createWebsite(String access_token) {
|
||||
final Integer tenantId = getTenantId();
|
||||
// 请求主服务器获取租户信息
|
||||
String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/tenant")
|
||||
.header("Authorization", access_token)
|
||||
.header("Tenantid", tenantId.toString())
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
final String data = jsonObject.getString("data");
|
||||
final Company company = JSONObject.parseObject(data, Company.class);
|
||||
if(company == null){
|
||||
throw new BusinessException("站点不存在");
|
||||
}
|
||||
// 创建网站记录
|
||||
final Website website = new Website();
|
||||
website.setTenantId(company.getTenantId());
|
||||
website.setWebsiteName(company.getShortName());
|
||||
website.setWebsiteLogo(company.getCompanyLogo());
|
||||
website.setWebsiteIcon("/favicon.ico");
|
||||
website.setWebsiteType("企业官网");
|
||||
website.setDomain(company.getDomain());
|
||||
website.setExpirationTime(company.getExpirationTime());
|
||||
website.setIndustryParent(company.getIndustryParent());
|
||||
website.setIndustryChild(company.getIndustryChild());
|
||||
website.setCompanyId(company.getCompanyId());
|
||||
website.setAddress(company.getAddress());
|
||||
website.setComments(company.getComments());
|
||||
website.setKeywords(company.getCompanyName());
|
||||
website.setUserId(company.getUserId());
|
||||
websiteService.save(website);
|
||||
|
||||
// 创建默认页面及导航
|
||||
final Navigation navigation = new Navigation();
|
||||
final Design design = new Design();
|
||||
// 1.首页
|
||||
design.setName("首页");
|
||||
design.setHome(1);
|
||||
design.setPath("/");
|
||||
design.setComponent("/pages/index");
|
||||
design.setSortNumber(0);
|
||||
designService.save(design);
|
||||
navigation.setTitle(design.getName());
|
||||
navigation.setPath(design.getPath());
|
||||
navigation.setComponent(design.getComponent());
|
||||
navigation.setHome(design.getHome());
|
||||
navigation.setPageId(design.getPageId());
|
||||
navigation.setSortNumber(0);
|
||||
navigation.setType(1);
|
||||
navigation.setPosition(1);
|
||||
navigationService.save(navigation);
|
||||
// 创建默认页面及导航
|
||||
final Navigation navigation = new Navigation();
|
||||
final Design design = new Design();
|
||||
// 1.首页
|
||||
design.setName("首页");
|
||||
design.setHome(1);
|
||||
design.setPath("/");
|
||||
design.setComponent("/pages/index");
|
||||
design.setSortNumber(0);
|
||||
designService.save(design);
|
||||
navigation.setTitle(design.getName());
|
||||
navigation.setPath(design.getPath());
|
||||
navigation.setComponent(design.getComponent());
|
||||
navigation.setHome(design.getHome());
|
||||
navigation.setPageId(design.getPageId());
|
||||
navigation.setSortNumber(0);
|
||||
navigation.setType(1);
|
||||
navigation.setPosition(1);
|
||||
navigationService.save(navigation);
|
||||
// // 2.关于我们
|
||||
// design.setName("关于我们");
|
||||
// design.setPath("/about");
|
||||
@@ -369,131 +371,131 @@ public class WebsiteController extends BaseController {
|
||||
// navigation.setType(1);
|
||||
// navigation.setPosition(1);
|
||||
// navigationService.save(navigation);
|
||||
// 添加字典
|
||||
final Dict dict = new Dict();
|
||||
dict.setDictName("路由方式");
|
||||
dict.setDictCode("navType");
|
||||
dict.setSortNumber(100);
|
||||
final boolean save = dictService.save(dict);
|
||||
final Integer dictId = dict.getDictId();
|
||||
final DictData dictData = new DictData();
|
||||
dictData.setDictDataName("uni.navigateTo");
|
||||
dictData.setDictDataCode("uni.navigateTo");
|
||||
dictData.setComments("保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面");
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("uni.redirectTo");
|
||||
dictData.setDictDataCode("uni.redirectTo");
|
||||
dictData.setComments("关闭当前页面,跳转到应用内的某个页面");
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("uni.reLaunch");
|
||||
dictData.setDictDataCode("uni.reLaunch");
|
||||
dictData.setComments("关闭所有页面,打开到应用内的某个页面");
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("uni.switchTab");
|
||||
dictData.setDictDataCode("uni.switchTab");
|
||||
dictData.setComments("跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面");
|
||||
dictDataService.save(dictData);
|
||||
// 网站配置参数
|
||||
List<WebsiteField> fields = new ArrayList<>();
|
||||
WebsiteField field = new WebsiteField();
|
||||
field.setType(0);
|
||||
field.setName("siteLogo");
|
||||
field.setValue(company.getCompanyLogo());
|
||||
field.setComments("网站LOGO");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("siteName");
|
||||
field.setValue(company.getShortName());
|
||||
field.setComments("网站名称");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("icpNo");
|
||||
field.setValue("-");
|
||||
field.setComments("备案号");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("qrcode");
|
||||
field.setValue("");
|
||||
field.setComments("公众号二维码");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("bottomBg");
|
||||
field.setValue("https://oss.wsdns.cn/20240717/13165035c35e4f25a6c9fbd3636c6292.png");
|
||||
field.setComments("网站底部背景图");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("address");
|
||||
field.setValue(company.getAddress());
|
||||
field.setComments("办公地址");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("tel");
|
||||
field.setValue(company.getTel());
|
||||
field.setComments("公司电话");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("domain");
|
||||
field.setValue(company.getDomain());
|
||||
field.setComments("网站域名");
|
||||
websiteFieldService.save(field);
|
||||
}
|
||||
|
||||
@ApiOperation("获取服务器时间")
|
||||
@GetMapping("/getServerTime")
|
||||
public ApiResult<?> getServerTime(){
|
||||
// 服务器时间
|
||||
final ServerTimeVO vo = new ServerTimeVO();
|
||||
final int hour = DateUtil.hour(DateUtil.date(), true);
|
||||
final int minute = DateUtil.minute(DateUtil.date());
|
||||
vo.setDate(DateUtil.date());
|
||||
vo.setToday(DateUtil.today());
|
||||
vo.setHour(hour);
|
||||
vo.setMinute(minute);
|
||||
vo.setHourMinute(String.format("%02d", hour).concat(String.format("%02d", minute)));
|
||||
final int compare = Integer.compare(Integer.valueOf(vo.getHourMinute()), 900);
|
||||
vo.setIsAfter(compare);
|
||||
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
if (orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getPayStatus,0)) > 0) {
|
||||
vo.setHasNoPayOrder(true);
|
||||
}
|
||||
}
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取未来一周的日期")
|
||||
@GetMapping("/getNext7day")
|
||||
public ApiResult<?> getNext7day(){
|
||||
List<Next7dayVO> dateList = new ArrayList<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Date date = DateUtils.addDays(new Date(), +i);
|
||||
String formatDate = sdf.format(date);
|
||||
String dateTime = sdf2.format(date);
|
||||
final Next7dayVO vo = new Next7dayVO();
|
||||
vo.setDate(dateTime);
|
||||
vo.setDateTime(formatDate);
|
||||
final DateTime parse = DateUtil.parse(formatDate);
|
||||
int dayOfWeek = DateUtil.dayOfWeek(parse);
|
||||
vo.setWeek(dayOfWeek - 1);
|
||||
dateList.add(vo);
|
||||
// 添加字典
|
||||
final Dict dict = new Dict();
|
||||
dict.setDictName("路由方式");
|
||||
dict.setDictCode("navType");
|
||||
dict.setSortNumber(100);
|
||||
final boolean save = dictService.save(dict);
|
||||
final Integer dictId = dict.getDictId();
|
||||
final DictData dictData = new DictData();
|
||||
dictData.setDictDataName("uni.navigateTo");
|
||||
dictData.setDictDataCode("uni.navigateTo");
|
||||
dictData.setComments("保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面");
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("uni.redirectTo");
|
||||
dictData.setDictDataCode("uni.redirectTo");
|
||||
dictData.setComments("关闭当前页面,跳转到应用内的某个页面");
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("uni.reLaunch");
|
||||
dictData.setDictDataCode("uni.reLaunch");
|
||||
dictData.setComments("关闭所有页面,打开到应用内的某个页面");
|
||||
dictDataService.save(dictData);
|
||||
dictData.setDictDataName("uni.switchTab");
|
||||
dictData.setDictDataCode("uni.switchTab");
|
||||
dictData.setComments("跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面");
|
||||
dictDataService.save(dictData);
|
||||
// 网站配置参数
|
||||
List<WebsiteField> fields = new ArrayList<>();
|
||||
WebsiteField field = new WebsiteField();
|
||||
field.setType(0);
|
||||
field.setName("siteLogo");
|
||||
field.setValue(company.getCompanyLogo());
|
||||
field.setComments("网站LOGO");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("siteName");
|
||||
field.setValue(company.getShortName());
|
||||
field.setComments("网站名称");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("icpNo");
|
||||
field.setValue("-");
|
||||
field.setComments("备案号");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("qrcode");
|
||||
field.setValue("");
|
||||
field.setComments("公众号二维码");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("bottomBg");
|
||||
field.setValue("https://oss.wsdns.cn/20240717/13165035c35e4f25a6c9fbd3636c6292.png");
|
||||
field.setComments("网站底部背景图");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("address");
|
||||
field.setValue(company.getAddress());
|
||||
field.setComments("办公地址");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("tel");
|
||||
field.setValue(company.getTel());
|
||||
field.setComments("公司电话");
|
||||
websiteFieldService.save(field);
|
||||
field.setName("domain");
|
||||
field.setValue(company.getDomain());
|
||||
field.setComments("网站域名");
|
||||
websiteFieldService.save(field);
|
||||
}
|
||||
|
||||
return success(dateList);
|
||||
}
|
||||
@ApiOperation("获取服务器时间")
|
||||
@GetMapping("/getServerTime")
|
||||
public ApiResult<?> getServerTime() {
|
||||
// 服务器时间
|
||||
final ServerTimeVO vo = new ServerTimeVO();
|
||||
final int hour = DateUtil.hour(DateUtil.date(), true);
|
||||
final int minute = DateUtil.minute(DateUtil.date());
|
||||
vo.setDate(DateUtil.date());
|
||||
vo.setToday(DateUtil.today());
|
||||
vo.setHour(hour);
|
||||
vo.setMinute(minute);
|
||||
vo.setHourMinute(String.format("%02d", hour).concat(String.format("%02d", minute)));
|
||||
final int compare = Integer.compare(Integer.valueOf(vo.getHourMinute()), 900);
|
||||
vo.setIsAfter(compare);
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:website:remove')")
|
||||
@ApiOperation("清除缓存")
|
||||
@DeleteMapping("/clearSiteInfo/{key}")
|
||||
public ApiResult<?> clearSiteInfo(@PathVariable("key") String key) {
|
||||
final String siteInfo = redisUtil.get(key);
|
||||
if(StrUtil.isNotBlank(siteInfo)){
|
||||
// 清除指定key
|
||||
redisUtil.delete(key);
|
||||
// 清除小程序缓存
|
||||
redisUtil.delete("MpInfo:".concat(getTenantId().toString()));
|
||||
// 清除网站缓存
|
||||
redisUtil.delete("SiteInfo:".concat(getTenantId().toString()));
|
||||
// 选择支付方式
|
||||
redisUtil.delete("SelectPayment:".concat(getTenantId().toString()));
|
||||
return success("清除成功");
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
if (orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getPayStatus, 0)) > 0) {
|
||||
vo.setHasNoPayOrder(true);
|
||||
}
|
||||
}
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取未来一周的日期")
|
||||
@GetMapping("/getNext7day")
|
||||
public ApiResult<?> getNext7day() {
|
||||
List<Next7dayVO> dateList = new ArrayList<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Date date = DateUtils.addDays(new Date(), +i);
|
||||
String formatDate = sdf.format(date);
|
||||
String dateTime = sdf2.format(date);
|
||||
final Next7dayVO vo = new Next7dayVO();
|
||||
vo.setDate(dateTime);
|
||||
vo.setDateTime(formatDate);
|
||||
final DateTime parse = DateUtil.parse(formatDate);
|
||||
int dayOfWeek = DateUtil.dayOfWeek(parse);
|
||||
vo.setWeek(dayOfWeek - 1);
|
||||
dateList.add(vo);
|
||||
}
|
||||
|
||||
return success(dateList);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:website:remove')")
|
||||
@ApiOperation("清除缓存")
|
||||
@DeleteMapping("/clearSiteInfo/{key}")
|
||||
public ApiResult<?> clearSiteInfo(@PathVariable("key") String key) {
|
||||
final String siteInfo = redisUtil.get(key);
|
||||
if (StrUtil.isNotBlank(siteInfo)) {
|
||||
// 清除指定key
|
||||
redisUtil.delete(key);
|
||||
// 清除小程序缓存
|
||||
redisUtil.delete("MpInfo:".concat(getTenantId().toString()));
|
||||
// 清除网站缓存
|
||||
redisUtil.delete("SiteInfo:".concat(getTenantId().toString()));
|
||||
// 选择支付方式
|
||||
redisUtil.delete("SelectPayment:".concat(getTenantId().toString()));
|
||||
return success("清除成功");
|
||||
}
|
||||
return success("清除失败");
|
||||
}
|
||||
return success("清除失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
src/main/java/com/gxwebsoft/cms/entity/DesignCategory.java
Normal file
57
src/main/java/com/gxwebsoft/cms/entity/DesignCategory.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.gxwebsoft.cms.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 设计征集报名分类
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-10-10 09:23:25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "DesignCategory对象", description = "设计征集报名分类")
|
||||
@TableName("cms_design_category")
|
||||
public class DesignCategory implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0已发布, 1待审核 2已驳回 3违规内容")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.gxwebsoft.cms.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -27,6 +25,8 @@ public class DesignCollect implements Serializable {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer categoryId;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
@@ -58,4 +58,6 @@ public class DesignCollect implements Serializable {
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private DesignCategory category;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.cms.entity.DesignCategory;
|
||||
import com.gxwebsoft.cms.param.DesignCategoryParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设计征集报名分类Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-10-10 09:23:25
|
||||
*/
|
||||
public interface DesignCategoryMapper extends BaseMapper<DesignCategory> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<DesignCategory>
|
||||
*/
|
||||
List<DesignCategory> selectPageRel(@Param("page") IPage<DesignCategory> page,
|
||||
@Param("param") DesignCategoryParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<DesignCategory> selectListRel(@Param("param") DesignCategoryParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.cms.mapper.DesignCategoryMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM cms_design_category a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.DesignCategory">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.DesignCategory">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -10,6 +10,9 @@
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.categoryId != null">
|
||||
AND a.category_id = #{param.categoryId}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
@@ -48,6 +51,7 @@
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.sort_number ASC, a.id DESC
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gxwebsoft.cms.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 设计征集报名分类查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-10-10 09:23:25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "DesignCategoryParam对象", description = "设计征集报名分类查询参数")
|
||||
public class DesignCategoryParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0已发布, 1待审核 2已驳回 3违规内容")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -26,6 +26,8 @@ public class DesignCollectParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
private Integer categoryId;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.cms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.cms.entity.DesignCategory;
|
||||
import com.gxwebsoft.cms.param.DesignCategoryParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设计征集报名分类Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-10-10 09:23:25
|
||||
*/
|
||||
public interface DesignCategoryService extends IService<DesignCategory> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<DesignCategory>
|
||||
*/
|
||||
PageResult<DesignCategory> pageRel(DesignCategoryParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<DesignCategory>
|
||||
*/
|
||||
List<DesignCategory> listRel(DesignCategoryParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return DesignCategory
|
||||
*/
|
||||
DesignCategory getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.cms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.cms.mapper.DesignCategoryMapper;
|
||||
import com.gxwebsoft.cms.service.DesignCategoryService;
|
||||
import com.gxwebsoft.cms.entity.DesignCategory;
|
||||
import com.gxwebsoft.cms.param.DesignCategoryParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设计征集报名分类Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-10-10 09:23:25
|
||||
*/
|
||||
@Service
|
||||
public class DesignCategoryServiceImpl extends ServiceImpl<DesignCategoryMapper, DesignCategory> implements DesignCategoryService {
|
||||
|
||||
@Override
|
||||
public PageResult<DesignCategory> pageRel(DesignCategoryParam param) {
|
||||
PageParam<DesignCategory, DesignCategoryParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<DesignCategory> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DesignCategory> listRel(DesignCategoryParam param) {
|
||||
List<DesignCategory> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<DesignCategory, DesignCategoryParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesignCategory getByIdRel(Integer id) {
|
||||
DesignCategoryParam param = new DesignCategoryParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.gxwebsoft.cms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.cms.mapper.DesignCollectMapper;
|
||||
import com.gxwebsoft.cms.service.DesignCategoryService;
|
||||
import com.gxwebsoft.cms.service.DesignCollectService;
|
||||
import com.gxwebsoft.cms.entity.DesignCollect;
|
||||
import com.gxwebsoft.cms.param.DesignCollectParam;
|
||||
@@ -9,6 +10,7 @@ import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -19,12 +21,17 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
public class DesignCollectServiceImpl extends ServiceImpl<DesignCollectMapper, DesignCollect> implements DesignCollectService {
|
||||
@Resource
|
||||
private DesignCategoryService designCategoryService;
|
||||
|
||||
@Override
|
||||
public PageResult<DesignCollect> pageRel(DesignCollectParam param) {
|
||||
PageParam<DesignCollect, DesignCollectParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<DesignCollect> list = baseMapper.selectPageRel(page, param);
|
||||
for (DesignCollect designCollect : list) {
|
||||
designCollect.setCategory(designCategoryService.getByIdRel(designCollect.getCategoryId()));
|
||||
}
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,17 @@ public class FileController extends BaseController {
|
||||
FileServerUtil.preview(file, getPdfOutDir(), config.getOpenOfficeHome(), response, request);
|
||||
}
|
||||
|
||||
@ApiOperation("下载原文件")
|
||||
@GetMapping("/qrcode/{dir}/{name:.+}")
|
||||
public void qrcode(@PathVariable("dir") String dir, @PathVariable("name") String name,
|
||||
HttpServletResponse response, HttpServletRequest request) {
|
||||
String path = dir + "/" + name;
|
||||
// FileRecord record = fileRecordService.getByIdPath(path);
|
||||
File file = new File(getUploadDir(), path);
|
||||
// String fileName = record == null ? file.getName() : record.getName();
|
||||
FileServerUtil.preview(file, true, name, null, null, response, request);
|
||||
}
|
||||
|
||||
@ApiOperation("下载原文件")
|
||||
@GetMapping("/download/{dir}/{name:.+}")
|
||||
public void download(@PathVariable("dir") String dir, @PathVariable("name") String name,
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -23,6 +25,7 @@ import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
|
||||
|
||||
@@ -36,157 +39,175 @@ import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KE
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-user")
|
||||
public class DealerUserController extends BaseController {
|
||||
@Resource
|
||||
private DealerUserService dealerUserService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
@Resource
|
||||
private DealerUserService dealerUserService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
|
||||
|
||||
@ApiOperation("生成专属二维码")
|
||||
@GetMapping("/getDealerUserQrcode")
|
||||
public ApiResult<?> getDealerUserQrcode() {
|
||||
final Integer loginUserId = getLoginUserId();
|
||||
if(loginUserId == null){
|
||||
return fail("请先登录");
|
||||
@ApiOperation("生成专属二维码")
|
||||
@GetMapping("/getDealerUserQrcode")
|
||||
public ApiResult<?> getDealerUserQrcode() {
|
||||
final Integer loginUserId = getLoginUserId();
|
||||
if (loginUserId == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
|
||||
final DealerUser dealerUser = dealerUserService.getByUserId(loginUserId);
|
||||
|
||||
// 生成小程序码
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + getAccessToken();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("scene", loginUserId);
|
||||
map.put("page", "package/dealer/invite");
|
||||
map.put("env_version", "trial"); // 正式版为"release",体验版为"trial",开发版为"develop"
|
||||
|
||||
// 获取图片 Buffer
|
||||
byte[] qrCode = HttpRequest.post(apiUrl)
|
||||
.body(JSON.toJSONString(map))
|
||||
.execute().bodyBytes();
|
||||
|
||||
// // 保存的文件名称
|
||||
final String fileName = loginUserId.toString().concat(".png");
|
||||
// 保存路径
|
||||
String filePath = getUploadDir().concat("user-code/") + fileName;
|
||||
File file = FileUtil.writeBytes(qrCode, filePath);
|
||||
|
||||
if (file != null) {
|
||||
final String qrcode = config.getFileServer().concat("/user-code/").concat(fileName);
|
||||
dealerUser.setQrcode(qrcode);
|
||||
dealerUserService.updateById(dealerUser);
|
||||
return success("操作成功", qrcode);
|
||||
}
|
||||
return success(qrCode);
|
||||
}
|
||||
|
||||
final DealerUser dealerUser = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>().eq(DealerUser::getUserId, loginUserId).last("limit 1"));
|
||||
|
||||
// 生成小程序码
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("path", "package/dealer/invite?id=" + loginUserId);
|
||||
map.put("env_version", "trial"); // 正式版为"release",体验版为"trial",开发版为"develop"
|
||||
|
||||
// 获取图片 Buffer
|
||||
byte[] qrCode = HttpRequest.post(apiUrl)
|
||||
.body(JSON.toJSONString(map))
|
||||
.execute().bodyBytes();
|
||||
|
||||
// 保存的文件名称
|
||||
final String fileName = loginUserId.toString().concat(".png");
|
||||
// 保存路径
|
||||
String filePath = getUploadDir().concat("user-code/") + fileName;
|
||||
File file = FileUtil.writeBytes(qrCode, filePath);
|
||||
|
||||
if (file != null) {
|
||||
final String qrcode = config.getFileServer().concat("/user-code/").concat(fileName);
|
||||
dealerUser.setQrcode(qrcode);
|
||||
dealerUserService.updateById(dealerUser);
|
||||
return success("操作成功",qrcode);
|
||||
}
|
||||
return success(dealerUser);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询分销商用户记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerUser>> page(DealerUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商用户记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerUser>> list(DealerUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询分销商用户记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerUser> get(@PathVariable("id") Integer id) {
|
||||
// 分销商信息
|
||||
final DealerUser dealerUser = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>()
|
||||
.eq(DealerUser::getUserId, id)
|
||||
.eq(DealerUser::getIsDelete, 0)
|
||||
.last("limit 1")
|
||||
);
|
||||
// 上级分销商
|
||||
final DealerUser dealerUser1 = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>()
|
||||
.eq(DealerUser::getUserId, dealerUser.getRefereeId())
|
||||
.eq(DealerUser::getIsDelete, 0));
|
||||
dealerUser.setDealerName(dealerUser1.getRealName());
|
||||
dealerUser.setDealerUser(dealerUser1);
|
||||
return success(dealerUser);
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商用户记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerUser dealerUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerUserService.save(dealerUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商用户记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerUser dealerUser) {
|
||||
if (dealerUserService.updateById(dealerUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商用户记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商用户记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerUser> list) {
|
||||
if (dealerUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商用户记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerUser> batchParam) {
|
||||
if (batchParam.update(dealerUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商用户记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
|
||||
private String getAccessToken() {
|
||||
String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString());
|
||||
// 从缓存获取access_token
|
||||
final String value = redisUtil.get(key);
|
||||
if (value != null) {
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(value);
|
||||
return response.getString("access_token");
|
||||
@ApiOperation("分页查询分销商用户记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerUser>> page(DealerUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerUserService.pageRel(param));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@ApiOperation("查询全部分销商用户记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerUser>> list(DealerUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询分销商用户记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerUser> get(@PathVariable("id") Integer id) {
|
||||
// 分销商信息
|
||||
final DealerUser dealerUser = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>()
|
||||
.eq(DealerUser::getUserId, id)
|
||||
.eq(DealerUser::getIsDelete, 0)
|
||||
.last("limit 1")
|
||||
);
|
||||
// 上级分销商
|
||||
if (dealerUser != null) {
|
||||
final DealerUser dealerUser1 = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>()
|
||||
.eq(DealerUser::getUserId, dealerUser.getRefereeId())
|
||||
.eq(DealerUser::getIsDelete, 0));
|
||||
if (dealerUser1 != null) {
|
||||
dealerUser.setDealerName(dealerUser1.getRealName());
|
||||
dealerUser.setDealerUser(dealerUser1);
|
||||
}
|
||||
}
|
||||
return success(dealerUser);
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商用户记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerUser dealerUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerUserService.save(dealerUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商用户记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerUser dealerUser) {
|
||||
if (dealerUserService.updateById(dealerUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商用户记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商用户记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerUser> list) {
|
||||
if (dealerUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商用户记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerUser> batchParam) {
|
||||
if (batchParam.update(dealerUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商用户记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
|
||||
private String getUploadDir() {
|
||||
return config.getUploadPath() + "file/";
|
||||
}
|
||||
private String getAccessToken() {
|
||||
String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString());
|
||||
// 从缓存获取access_token
|
||||
final String value = redisUtil.get(key);
|
||||
if (value != null) {
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(value);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
// 组装url参数
|
||||
String url = apiUrl.concat("?grant_type=client_credential")
|
||||
.concat("&appid=").concat("wx309c034f7556aeb1")
|
||||
.concat("&secret=").concat("c8fa9e5ee2edc8c0bbd5f9c38df244ec");
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(url);
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(result);
|
||||
if (response.getString("access_token") != null) {
|
||||
// 存入缓存
|
||||
redisUtil.set(key, result, 7000L, TimeUnit.SECONDS);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private String getUploadDir() {
|
||||
return config.getUploadPath() + "file/";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,21 +36,21 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods")
|
||||
public class GoodsController extends BaseController {
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsSpecService goodsSpecService;
|
||||
@Resource
|
||||
private GoodsSkuService goodsSkuService;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsSpecService goodsSpecService;
|
||||
@Resource
|
||||
private GoodsSkuService goodsSkuService;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
|
||||
@ApiOperation("分页查询商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
||||
final User loginUser = getLoginUser();
|
||||
param.setLoginUser(loginUser);
|
||||
return success(goodsService.pageRel(param));
|
||||
final User loginUser = getLoginUser();
|
||||
param.setLoginUser(loginUser);
|
||||
return success(goodsService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品记录表")
|
||||
@@ -64,143 +64,149 @@ public class GoodsController extends BaseController {
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Goods> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
final Goods goods = goodsService.getByIdRel(id);
|
||||
if (getLoginUser() != null) {
|
||||
// 经销商
|
||||
if (getLoginUser().getGradeId().equals(33)) {
|
||||
if (goods.getDealerGift()) goods.setShowGift(true);
|
||||
final Goods goods = goodsService.getByIdRel(id);
|
||||
if (getLoginUser() != null) {
|
||||
// 经销商
|
||||
if (getLoginUser().getGradeId().equals(33)) {
|
||||
if (goods.getDealerGift()) goods.setShowGift(true);
|
||||
}
|
||||
// 会员店
|
||||
if (getLoginUser().getGradeId().equals(31)) {
|
||||
if (goods.getPriceGift()) goods.setShowGift(true);
|
||||
}
|
||||
}
|
||||
// 会员店
|
||||
if (getLoginUser().getGradeId().equals(31)) {
|
||||
if (goods.getPriceGift()) goods.setShowGift(true);
|
||||
|
||||
// 提取specValue
|
||||
final GoodsSpec spec = goodsSpecService.getOne(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, id).last("limit 1"));
|
||||
if (spec != null) {
|
||||
final String specValue = spec.getSpecValue();
|
||||
final Object object = JSONUtil.parseObject(specValue, Object.class);
|
||||
goods.setGoodsSpecValue(object);
|
||||
}
|
||||
}
|
||||
|
||||
// 提取specValue
|
||||
final GoodsSpec spec = goodsSpecService.getOne(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, id).last("limit 1"));
|
||||
if (spec != null) {
|
||||
final String specValue = spec.getSpecValue();
|
||||
final Object object = JSONUtil.parseObject(specValue, Object.class);
|
||||
goods.setGoodsSpecValue(object);
|
||||
}
|
||||
// 整理商品价格
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
if(loginUser.getGradeId().equals(33)){
|
||||
goods.setPrice(goods.getDealerPrice());
|
||||
// 整理商品价格
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
if (loginUser.getGradeId().equals(33)) {
|
||||
goods.setPrice(goods.getDealerPrice());
|
||||
}
|
||||
if (loginUser.getGradeId().equals(0)) {
|
||||
goods.setPrice(goods.getSalePrice());
|
||||
}
|
||||
} else {
|
||||
goods.setPrice(goods.getSalePrice());
|
||||
}
|
||||
if(loginUser.getGradeId().equals(0)){
|
||||
goods.setPrice(goods.getSalePrice());
|
||||
// 店铺信息
|
||||
if (goods.getMerchantId() != null) {
|
||||
Merchant merchant = merchantService.getById(goods.getMerchantId());
|
||||
goods.setMerchant(merchant);
|
||||
if (merchant != null) {
|
||||
goods.setMerchantName(merchant.getMerchantName());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
goods.setPrice(goods.getSalePrice());
|
||||
}
|
||||
// 店铺信息
|
||||
goods.setMerchant(merchantService.getOne(new LambdaUpdateWrapper<Merchant>().eq(Merchant::getMerchantId, goods.getMerchantId())));
|
||||
|
||||
return success(goods);
|
||||
return success(goods);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@ApiOperation("添加商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Goods goods) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsService.save(goods)) {
|
||||
// 保存商品规格及sku信息
|
||||
goodsService.saveBatchByAsync(goods);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@ApiOperation("修改商品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Goods goods) {
|
||||
if (goodsService.updateById(goods)) {
|
||||
// 删除旧信息
|
||||
goodsSpecService.remove(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, goods.getGoodsId()));
|
||||
goodsSkuService.remove(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getGoodsId()));
|
||||
// 保存商品规格及sku信息
|
||||
goodsService.saveBatchByAsync(goods);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@ApiOperation("删除商品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@ApiOperation("批量添加商品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Goods> list) {
|
||||
if (goodsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@ApiOperation("批量修改商品记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Goods> batchParam) {
|
||||
if (batchParam.update(goodsService, "goods_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@ApiOperation("批量删除商品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<Map<String, Integer>> data(GoodsParam param) {
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
final LambdaQueryWrapper<Goods> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (param.getMerchantId() != null) {
|
||||
wrapper.eq(Goods::getMerchantId,param.getMerchantId());
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@ApiOperation("添加商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Goods goods) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsService.save(goods)) {
|
||||
// 保存商品规格及sku信息
|
||||
goodsService.saveBatchByAsync(goods);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
Integer totalNum = goodsService.count(
|
||||
wrapper.eq(Goods::getIsShow,1).gt(Goods::getStock,0)
|
||||
);
|
||||
data.put("totalNum", totalNum);
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@ApiOperation("修改商品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Goods goods) {
|
||||
if (goodsService.updateById(goods)) {
|
||||
// 删除旧信息
|
||||
goodsSpecService.remove(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, goods.getGoodsId()));
|
||||
goodsSkuService.remove(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getGoodsId()));
|
||||
// 保存商品规格及sku信息
|
||||
goodsService.saveBatchByAsync(goods);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
Integer totalNum2 = goodsService.count(
|
||||
wrapper.eq(Goods::getIsShow,0)
|
||||
);
|
||||
data.put("totalNum2", totalNum2);
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@ApiOperation("删除商品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
Integer totalNum3 = goodsService.count(
|
||||
wrapper.eq(Goods::getStock,0)
|
||||
);
|
||||
data.put("totalNum3", totalNum3);
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@ApiOperation("批量添加商品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Goods> list) {
|
||||
if (goodsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
// 下架已售罄的商品
|
||||
goodsService.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getStock,0).eq(Goods::getIsShow,1).set(Goods::getIsShow,0));
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@ApiOperation("批量修改商品记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Goods> batchParam) {
|
||||
if (batchParam.update(goodsService, "goods_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
return success(data);
|
||||
}
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@ApiOperation("批量删除商品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<Map<String, Integer>> data(GoodsParam param) {
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
final LambdaQueryWrapper<Goods> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (param.getMerchantId() != null) {
|
||||
wrapper.eq(Goods::getMerchantId, param.getMerchantId());
|
||||
}
|
||||
|
||||
Integer totalNum = goodsService.count(
|
||||
wrapper.eq(Goods::getIsShow, 1).gt(Goods::getStock, 0)
|
||||
);
|
||||
data.put("totalNum", totalNum);
|
||||
|
||||
Integer totalNum2 = goodsService.count(
|
||||
wrapper.eq(Goods::getIsShow, 0)
|
||||
);
|
||||
data.put("totalNum2", totalNum2);
|
||||
|
||||
Integer totalNum3 = goodsService.count(
|
||||
wrapper.eq(Goods::getStock, 0)
|
||||
);
|
||||
data.put("totalNum3", totalNum3);
|
||||
|
||||
// 下架已售罄的商品
|
||||
goodsService.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getStock, 0).eq(Goods::getIsShow, 1).set(Goods::getIsShow, 0));
|
||||
|
||||
return success(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.RequestUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.entity.DealerUser;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.entity.MerchantAccount;
|
||||
import com.gxwebsoft.shop.service.DealerUserService;
|
||||
import com.gxwebsoft.shop.service.MerchantApplyService;
|
||||
import com.gxwebsoft.shop.entity.MerchantApply;
|
||||
import com.gxwebsoft.shop.param.MerchantApplyParam;
|
||||
@@ -47,6 +49,8 @@ public class MerchantApplyController extends BaseController {
|
||||
private MerchantService merchantService;
|
||||
@Resource
|
||||
private RequestUtil requestUtil;
|
||||
@Resource
|
||||
private DealerUserService dealerUserService;
|
||||
|
||||
@ApiOperation("分页查询商户入驻申请")
|
||||
@GetMapping("/page")
|
||||
@@ -115,6 +119,7 @@ public class MerchantApplyController extends BaseController {
|
||||
case "供应商" -> 34;
|
||||
default -> gradeId;
|
||||
};
|
||||
loingUser.setGradeName(one.getShopType());
|
||||
} else {
|
||||
final Merchant merchant = new Merchant();
|
||||
BeanUtils.copyProperties(merchantApply, merchant);
|
||||
@@ -129,9 +134,11 @@ public class MerchantApplyController extends BaseController {
|
||||
case "供应商" -> 34;
|
||||
default -> gradeId;
|
||||
};
|
||||
loingUser.setGradeName(merchant.getShopType());
|
||||
}
|
||||
loingUser.setGradeId(gradeId);
|
||||
|
||||
|
||||
// TODO 创建商户账号
|
||||
requestUtil.setAccessToken(JwtUtil.getAccessToken(request));
|
||||
requestUtil.setTenantId(getTenantId().toString());
|
||||
@@ -141,6 +148,31 @@ public class MerchantApplyController extends BaseController {
|
||||
// TODO 更新用户表的商户ID
|
||||
requestUtil.updateUserMerchantId(user);
|
||||
|
||||
DealerUser check = dealerUserService.getByUserId(merchantApply.getUserId());
|
||||
if (check == null) {
|
||||
DealerUser dealerUser = new DealerUser();
|
||||
dealerUser.setUserId(merchantApply.getUserId());
|
||||
dealerUser.setRealName(merchantApply.getRealName());
|
||||
dealerUser.setMobile(merchantApply.getPhone());
|
||||
dealerUserService.save(dealerUser);
|
||||
User parentUser = requestUtil.getParent(merchantApply.getUserId());
|
||||
if (parentUser != null) {
|
||||
dealerUser.setRefereeId(parentUser.getUserId());
|
||||
if (merchantApply.getRefereeId() != null) {
|
||||
// 上级
|
||||
DealerUser dealerUser1 = dealerUserService.getByUserId(merchantApply.getRefereeId());
|
||||
dealerUser1.setFirstNum(dealerUser1.getFirstNum() + 1);
|
||||
dealerUserService.updateById(dealerUser1);
|
||||
|
||||
if (dealerUser1.getRefereeId() != null && dealerUser1.getRefereeId() != 0) {
|
||||
DealerUser dealerUser2 = dealerUserService.getByUserId(dealerUser1.getRefereeId());
|
||||
dealerUser2.setSecondNum(dealerUser2.getSecondNum() + 1);
|
||||
dealerUserService.updateById(dealerUser2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// TODO 驳回
|
||||
|
||||
|
||||
@@ -282,6 +282,7 @@ public class OrderController extends BaseController {
|
||||
d.setDateTime(DateUtil.date());
|
||||
d.setUserId(getLoginUser().getUserId());
|
||||
d.setExpirationTime(order.getExpirationTime());
|
||||
d.setTotalNum(d.getCartNum());
|
||||
});
|
||||
orderGoodsService.saveBatch(order.getGoodsList());
|
||||
}
|
||||
@@ -355,11 +356,11 @@ public class OrderController extends BaseController {
|
||||
return success("下单成功", orderService.createWxOrder(order));
|
||||
}
|
||||
}
|
||||
String filepath = uploadPath + "qrcode/" + getTenantId();
|
||||
String filepath = uploadPath + "qr/";
|
||||
if (!FileUtil.exist(filepath)) FileUtil.mkdir(filepath);
|
||||
String filename = "/friendPay_" + order.getOrderId() + ".png";
|
||||
weChatController.makeQr(request, filepath + filename, "orderId=" + order.getOrderId(), "package/order/friendPay");
|
||||
return success("下单成功", "file/qrcode/" + getTenantId() + filename);
|
||||
return success("下单成功", "file/qr"+ filename);
|
||||
}
|
||||
return fail("支付失败");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WeChatController extends BaseController {
|
||||
@ApiOperation("好友代付二维码")
|
||||
@PostMapping("/friend-pay-qr")
|
||||
public ApiResult<String> makeFriendPayQr(@RequestBody Order order, HttpServletRequest request){
|
||||
String filepath = uploadPath + "qrcode/" + getTenantId();
|
||||
String filepath = uploadPath + "qr/";
|
||||
if (!FileUtil.exist(filepath)) FileUtil.mkdir(filepath);
|
||||
String filename = "/friendPay_" + order.getOrderId() + ".png";
|
||||
if (FileUtil.exist(filepath + "/" + filename)) return success("生成成功", "file/qrcode/" + getTenantId() + filename);
|
||||
@@ -54,7 +54,7 @@ public class WeChatController extends BaseController {
|
||||
} catch (IOException | WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return success("生成成功", "file/qrcode/" + getTenantId() + filename);
|
||||
return success("生成成功", "file/qr" + filename);
|
||||
}
|
||||
|
||||
public void makeQr(HttpServletRequest request, String filename, String scene, String page) throws IOException, WxErrorException {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -10,6 +12,7 @@ import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -123,4 +126,6 @@ public class MerchantApply implements Serializable {
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer refereeId;
|
||||
}
|
||||
|
||||
@@ -113,4 +113,7 @@ public class OrderGoods implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private Goods goods;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer cartNum;
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface DealerUserService extends IService<DealerUser> {
|
||||
*/
|
||||
DealerUser getByIdRel(Integer id);
|
||||
|
||||
DealerUser getByUserId(Integer userId);
|
||||
}
|
||||
|
||||
@@ -44,4 +44,11 @@ public class DealerUserServiceImpl extends ServiceImpl<DealerUserMapper, DealerU
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealerUser getByUserId(Integer userId) {
|
||||
DealerUserParam param = new DealerUserParam();
|
||||
param.setUserId(userId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,6 +93,13 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (d.getPriceGift()) d.setShowGift(true);
|
||||
}
|
||||
}
|
||||
if (d.getMerchantId() != null) {
|
||||
Merchant merchant = merchantService.getById(d.getMerchantId());
|
||||
d.setMerchant(merchant);
|
||||
if (merchant != null) {
|
||||
d.setMerchantName(merchant.getMerchantName());
|
||||
}
|
||||
}
|
||||
// d.setGoodsSkus(collectSkus.get(d.getGoodsId()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,14 +134,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
if (!CollectionUtils.isEmpty(orderGoodsList)) {
|
||||
for (OrderGoods orderGoods : orderGoodsList) {
|
||||
Goods goods = goodsService.getById(orderGoods.getGoodsId());
|
||||
if (param.getLoginUser() != null) {
|
||||
// 经销商
|
||||
if (param.getLoginUser().getGradeId().equals(33)) {
|
||||
if (goods.getDealerGift()) goods.setShowGift(true);
|
||||
}
|
||||
// 会员店
|
||||
if (param.getLoginUser().getGradeId().equals(31)) {
|
||||
if (goods.getPriceGift()) goods.setShowGift(true);
|
||||
if (goods != null) {
|
||||
if (param.getLoginUser() != null) {
|
||||
// 经销商
|
||||
if (param.getLoginUser().getGradeId().equals(33)) {
|
||||
if (goods.getDealerGift()) goods.setShowGift(true);
|
||||
}
|
||||
// 会员店
|
||||
if (param.getLoginUser().getGradeId().equals(31)) {
|
||||
if (goods.getPriceGift()) goods.setShowGift(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
orderGoods.setGoods(goods);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: modules
|
||||
password: 8YdLnk7KsPAyDXGA
|
||||
url: jdbc:mysql://47.119.165.234:3308/nbg?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: nbg
|
||||
password: 5jk3J2Ah6LxCXksb
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: modules
|
||||
password: 8YdLnk7KsPAyDXGA
|
||||
url: jdbc:mysql://127.0.0.1:3308/nbg?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: nbg
|
||||
password: 5jk3J2Ah6LxCXksb
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
@@ -25,7 +25,8 @@ socketio:
|
||||
config:
|
||||
# 生产环境接口
|
||||
server-url: https://server.gxwebsoft.com/api
|
||||
upload-path: /www/wwwroot/file.ws/
|
||||
# upload-path: /www/wwwroot/file.ws/
|
||||
upload-path: /www/jar/nbg/file/
|
||||
|
||||
# 阿里云OSS云存储
|
||||
endpoint: https://oss-cn-shenzhen.aliyuncs.com
|
||||
|
||||
@@ -37,10 +37,10 @@ public class CmsGenerator {
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/nbg?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "modules";
|
||||
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
|
||||
private static final String DB_USERNAME = "nbg";
|
||||
private static final String DB_PASSWORD = "5jk3J2Ah6LxCXksb";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
@@ -71,8 +71,8 @@ public class CmsGenerator {
|
||||
// "cms_mp_field"
|
||||
// "cms_mp_ad"
|
||||
// "cms_components"
|
||||
"cms_design_collect",
|
||||
"cms_design_sign_up"
|
||||
// "cms_design_collect",
|
||||
"cms_design_category"
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
|
||||
@@ -38,10 +38,10 @@ public class ShopGenerator {
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/nbg?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "modules";
|
||||
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
|
||||
private static final String DB_USERNAME = "nbg";
|
||||
private static final String DB_PASSWORD = "5jk3J2Ah6LxCXksb";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
|
||||
2240
websoft-modules.log
Normal file
2240
websoft-modules.log
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user