zjh
2024-07-09 92614e60db568c9dc2e9cc7806821fb97646545b
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysConfigController.java
@@ -1,24 +1,25 @@
package com.ltkj.web.controller.system;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ltkj.common.core.domain.entity.SysMenu;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.hosp.domain.DictHosp;
import com.ltkj.hosp.service.IDictHospService;
import com.ltkj.system.service.ISysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.annotation.Log;
import com.ltkj.common.constant.UserConstants;
import com.ltkj.common.core.controller.BaseController;
@@ -42,6 +43,11 @@
    private ISysConfigService configService;
    @Autowired
    private ISysMenuService menuService;
    @Resource
    private IDictHospService dictHospService;
    @Value ("${token.secret_key}")
    private String secret;
    /**
     * 获取参数配置列表
     */
@@ -152,4 +158,24 @@
        return success();
    }
    @GetMapping ("/zx")//执行
    public AjaxResult zx(@RequestParam int day) {
        try {
            List<DictHosp> list = dictHospService.list();
            DateTime dateTime1 = DateUtil.offsetMonth(new Date(), day);
            for (DictHosp dictHosp : list) {
                String mallMerchantSecretKey = SecurityUtils.getMallMerchantSecretKey(secret, dictHosp.getHospAreaId(), dictHosp.getHospAreaName(), dateTime1);
                dictHosp.setSecretKey(mallMerchantSecretKey);
                dictHosp.setExpirationTime(dateTime1);
                dictHosp.setUpdateTime(new Date());
                dictHospService.updateById(dictHosp);
            }
            return AjaxResult.success();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.error();
    }
}